Show correct line numbers in generated source lines for common tests#1834
Merged
Conversation
For CUDA/HIP and DPCPP, we create separate copies of the source files using configure_file(...) to apply different CMake file properties to them. For the compiler to report error messages with the correct source file name, this adds a #line preprocessor statement to the top of these generated files.
upsj
commented
Apr 20, 2025
| // | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| /*@GKO_PREPROCESSOR_FILENAME_HELPER@*/ |
Member
Author
There was a problem hiding this comment.
I am using this weird comment structure to make sure both the original file and the generated file are valid C++ code. The ´#line` directive can start after a comment, but afaik it can't end with a comment, so that needs to be in the next line.
pratikvn
reviewed
Apr 20, 2025
| // | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| /*@GKO_PREPROCESSOR_FILENAME_HELPER@*/ |
Member
There was a problem hiding this comment.
Maybe I am missing something, wouldn't this be now after preprocessing be /*/*#line 5 .... */*/ ?
Member
There was a problem hiding this comment.
Okay, the above comment clarifies it. :)
Member
Author
There was a problem hiding this comment.
The actual string will be
/**/
#line 5 "file.cpp"
/**/
pratikvn
approved these changes
Apr 20, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For CUDA/HIP and DPCPP, we create separate copies of the source files using configure_file(...) to apply different CMake file properties to them. For the compiler to report error messages with the correct source file name, this adds a #line preprocessor statement to the top of these generated files.