@@ -272,10 +272,18 @@ void PrintPPOutputPPCallbacks::WriteLineInfo(unsigned LineNo,
272272
273273 // Emit #line directives or GNU line markers depending on what mode we're in.
274274 if (UseLineDirectives) {
275- *OS << " #line" << ' ' << LineNo << ' ' << ' "' ;
276- OS->write_escaped (CurFilename);
275+ if (CurFilename != PP.getPreprocessorOpts ().IncludeFooter &&
276+ CurFilename != PP.getPreprocessorOpts ().IncludeHeader ) {
277+ *OS << " #line" << ' ' << LineNo << ' ' << ' "' ;
278+ OS->write_escaped (CurFilename);
279+ *OS << ' "' ;
280+ }
281+ // *OS << "#line" << ' ' << LineNo << ' ' << '"';
282+ // OS->write_escaped(CurFilename);
277283 *OS << ' "' ;
278284 } else {
285+ if (CurFilename != PP.getPreprocessorOpts ().IncludeFooter &&
286+ CurFilename != PP.getPreprocessorOpts ().IncludeHeader ) {
279287 *OS << ' #' << ' ' << LineNo << ' ' << ' "' ;
280288 OS->write_escaped (CurFilename);
281289 *OS << ' "' ;
@@ -287,6 +295,7 @@ void PrintPPOutputPPCallbacks::WriteLineInfo(unsigned LineNo,
287295 OS->write (" 3" , 2 );
288296 else if (FileType == SrcMgr::C_ExternCSystem)
289297 OS->write (" 3 4" , 4 );
298+ }
290299 }
291300 *OS << ' \n ' ;
292301}
@@ -417,13 +426,26 @@ void PrintPPOutputPPCallbacks::FileChanged(SourceLocation Loc,
417426
418427 switch (Reason) {
419428 case PPCallbacks::EnterFile:
429+ #if 0
430+ // Don't print the header and footer lines in the pre-processed output.
431+ if (CurFilename != PP.getPreprocessorOpts().IncludeFooter &&
432+ CurFilename != PP.getPreprocessorOpts().IncludeHeader)
433+ #endif
420434 WriteLineInfo (CurLine, " 1" , 2 );
421435 break ;
422436 case PPCallbacks::ExitFile:
437+ #if 0
438+ if (CurFilename != PP.getPreprocessorOpts().IncludeFooter &&
439+ CurFilename != PP.getPreprocessorOpts().IncludeHeader)
440+ #endif
423441 WriteLineInfo (CurLine, " 2" , 2 );
424442 break ;
425443 case PPCallbacks::SystemHeaderPragma:
426444 case PPCallbacks::RenameFile:
445+ #if 0
446+ if (CurFilename != PP.getPreprocessorOpts().IncludeFooter &&
447+ CurFilename != PP.getPreprocessorOpts().IncludeHeader)
448+ #endif
427449 WriteLineInfo (CurLine);
428450 break ;
429451 }
@@ -914,7 +936,7 @@ static void PrintIncludeFooter(Preprocessor &PP, SourceLocation Loc,
914936 FileID FooterFileID = SourceMgr.ComputeValidFooterFileID (Footer);
915937 StringRef FooterContentBuffer = SourceMgr.getBufferData (FooterFileID);
916938 // print out the name of the integration footer.
917- Callbacks->WriteFooterInfo (Footer);
939+ // Callbacks->WriteFooterInfo(Footer);
918940 SmallVector<StringRef, 8 > FooterContentArr;
919941 FooterContentBuffer.split (FooterContentArr, ' \r ' );
920942 // print out the content of the integration footer.
@@ -1187,6 +1209,7 @@ void clang::DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream *OS,
11871209 PrintPreprocessedTokens (PP, Tok, Callbacks);
11881210 *OS << ' \n ' ;
11891211
1212+ #if 0
11901213 if (!PP.getPreprocessorOpts().IncludeFooter.empty() &&
11911214 !PP.IncludeFooterProcessed) {
11921215 assert(PP.getLangOpts().SYCLIsHost &&
@@ -1195,7 +1218,7 @@ void clang::DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream *OS,
11951218 PrintIncludeFooter(PP, Loc, PP.getPreprocessorOpts().IncludeFooter,
11961219 Callbacks);
11971220 }
1198-
1221+ # endif
11991222 // Remove the handlers we just added to leave the preprocessor in a sane state
12001223 // so that it can be reused (for example by a clang::Parser instance).
12011224 PP.RemovePragmaHandler (MicrosoftExtHandler.get ());
0 commit comments