diff options
-rw-r--r-- | lib/Lex/Pragma.cpp | 18 | ||||
-rw-r--r-- | test/Preprocessor/pragma_sysheader.c | 3 | ||||
-rw-r--r-- | test/Preprocessor/pragma_sysheader.h | 4 |
3 files changed, 23 insertions, 2 deletions
diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp index ce5934134f..9776c2cfbd 100644 --- a/lib/Lex/Pragma.cpp +++ b/lib/Lex/Pragma.cpp @@ -195,8 +195,10 @@ void Preprocessor::HandlePragmaOnce(Token &OnceTok) { void Preprocessor::HandlePragmaMark() { assert(CurPPLexer && "No current lexer?"); - if (CurLexer) CurLexer->ReadToEndOfLine(); - else CurPTHLexer->DiscardToEndOfLine(); + if (CurLexer) + CurLexer->ReadToEndOfLine(); + else + CurPTHLexer->DiscardToEndOfLine(); } @@ -254,6 +256,18 @@ void Preprocessor::HandlePragmaSystemHeader(Token &SysHeaderTok) { // Mark the file as a system header. HeaderInfo.MarkFileSystemHeader(TheLexer->getFileEntry()); + + PresumedLoc PLoc = SourceMgr.getPresumedLoc(SysHeaderTok.getLocation()); + unsigned FilenameLen = strlen(PLoc.getFilename()); + unsigned FilenameID = SourceMgr.getLineTableFilenameID(PLoc.getFilename(), + FilenameLen); + + // Emit a line marker. This will change any source locations from this point + // forward to realize they are in a system header. + // Create a line note with this information. + SourceMgr.AddLineNote(SysHeaderTok.getLocation(), PLoc.getLine(), FilenameID, + false, false, true, false); + // Notify the client, if desired, that we are in a new source file. if (Callbacks) Callbacks->FileChanged(SysHeaderTok.getLocation(), diff --git a/test/Preprocessor/pragma_sysheader.c b/test/Preprocessor/pragma_sysheader.c new file mode 100644 index 0000000000..49082b8c09 --- /dev/null +++ b/test/Preprocessor/pragma_sysheader.c @@ -0,0 +1,3 @@ +// RUN: clang -verify -pedantic %s -fsyntax-only +// rdar://6899937 +#include "pragma_sysheader.h" diff --git a/test/Preprocessor/pragma_sysheader.h b/test/Preprocessor/pragma_sysheader.h new file mode 100644 index 0000000000..b79bde584a --- /dev/null +++ b/test/Preprocessor/pragma_sysheader.h @@ -0,0 +1,4 @@ +#pragma GCC system_header +typedef int x; +typedef int x; + |