-
Notifications
You must be signed in to change notification settings - Fork 795
[SYCL] Don't print the header and footer in the preprocessed output. #15634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
d8b91f9
a87ef5d
bf359e9
e4d04d1
19806c1
6eadb5a
eda1496
10d54cc
09f735e
82c3d86
be076b4
83794f6
7fe537c
8d48644
e408c27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1663,6 +1663,13 @@ void clang::InitializePreprocessor(Preprocessor &PP, | |
| AddImplicitInclude(Builder, Path); | ||
| } | ||
|
|
||
| // Process -include-internal-header directive. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment accurate? Is the 'processing' happening inside the function call? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. A |
||
| if (!LangOpts.SYCLIsDevice) { | ||
| if (!InitOpts.IncludeHeader.empty()) { | ||
| AddImplicitInclude(Builder, InitOpts.IncludeHeader); | ||
| } | ||
| } | ||
|
|
||
| // Instruct the preprocessor to skip the preamble. | ||
| PP.setSkipMainFilePreamble(InitOpts.PrecompiledPreambleBytes.first, | ||
| InitOpts.PrecompiledPreambleBytes.second); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -265,29 +265,40 @@ void PrintPPOutputPPCallbacks::WriteFooterContent(StringRef CodeFooter) { | |||||||||||||||||||||
| *OS << '\n'; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| static bool is_separator(char value) { return value == '\\'; } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| void PrintPPOutputPPCallbacks::WriteLineInfo(unsigned LineNo, | ||||||||||||||||||||||
| const char *Extra, | ||||||||||||||||||||||
| unsigned ExtraLen) { | ||||||||||||||||||||||
| startNewLineIfNeeded(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Emit #line directives or GNU line markers depending on what mode we're in. | ||||||||||||||||||||||
| if (UseLineDirectives) { | ||||||||||||||||||||||
| *OS << "#line" << ' ' << LineNo << ' ' << '"'; | ||||||||||||||||||||||
| OS->write_escaped(CurFilename); | ||||||||||||||||||||||
| *OS << '"'; | ||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
| *OS << '#' << ' ' << LineNo << ' ' << '"'; | ||||||||||||||||||||||
| OS->write_escaped(CurFilename); | ||||||||||||||||||||||
| *OS << '"'; | ||||||||||||||||||||||
| StringRef CurFilenameWithNoLeaningDotSlash = | ||||||||||||||||||||||
| llvm::sys::path::remove_leading_dotbackslash(CurFilename.str()); | ||||||||||||||||||||||
| if ((CurFilenameWithNoLeaningDotSlash == | ||||||||||||||||||||||
| PP.getPreprocessorOpts().IncludeFooter) || | ||||||||||||||||||||||
| CurFilenameWithNoLeaningDotSlash == | ||||||||||||||||||||||
|
||||||||||||||||||||||
| StringRef CurFilenameWithNoLeaningDotSlash = | |
| llvm::sys::path::remove_leading_dotbackslash(CurFilename.str()); | |
| if ((CurFilenameWithNoLeaningDotSlash == | |
| PP.getPreprocessorOpts().IncludeFooter) || | |
| CurFilenameWithNoLeaningDotSlash == | |
| StringRef CurFilenameWithNoLeadingDotSlash = | |
| llvm::sys::path::remove_leading_dotbackslash(CurFilename.str()); | |
| if ((CurFilenameWithNoLeadingDotSlash == | |
| PP.getPreprocessorOpts().IncludeFooter) || | |
| CurFilenameWithNoLeadingDotSlash == |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation starting this line seems off to me. Please check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a possibility where we want to include header and not footer...or the other way around? Just wondering if we need two options here.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. @premanandrao What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior of
-include-internal-headerand-include-internal-footeris more than just the ability to pass in a file to be included, it also designates where in the preprocessing the file is expanded, so we need to have 2 options.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Mike!