diff options
author | Chris Lattner <sabre@nondot.org> | 2009-06-15 05:02:34 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-06-15 05:02:34 +0000 |
commit | 6896a371e302c63ce3d4a99ad2c32e42dde6a9e4 (patch) | |
tree | 84f1540af63a0a39327b2160bb93d02f2628de97 /lib | |
parent | a81aae2cb8bc839deea6d4a6e676e10c16c4f643 (diff) |
Fix #pragma GCC system_header by making it insert a virtual linemarker into
the file at the point of the pragma. This allows clang to know that all
sourcelocations after the pragma are in a system header.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73376 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Lex/Pragma.cpp | 18 |
1 files changed, 16 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(), |