From: Chris Lattner Date: Fri, 30 Jan 2009 18:44:17 +0000 (+0000) Subject: avoid emitting a bogus line marker for the top level #include X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=71d8bfb560735e8d47105cf434409ed347267830;p=clang avoid emitting a bogus line marker for the top level #include location. We now -E a file containing "foo" into: # 1 "t.c" # 1 "t.c" 1 # 1 "" 1 # 1 "t.c" 2 foo instead of: # 1 "t.c" # 1 "t.c" 1 # 0 "t.c" # 1 "" 1 # 1 "t.c" 2 foo git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63405 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Driver/PrintPreprocessedOutput.cpp b/Driver/PrintPreprocessedOutput.cpp index 5c4a140fa9..2c764ade00 100644 --- a/Driver/PrintPreprocessedOutput.cpp +++ b/Driver/PrintPreprocessedOutput.cpp @@ -150,7 +150,9 @@ void PrintPPOutputPPCallbacks::FileChanged(SourceLocation Loc, // #include directive was at. SourceManager &SourceMgr = PP.getSourceManager(); if (Reason == PPCallbacks::EnterFile) { - MoveToLine(SourceMgr.getPresumedLoc(Loc).getIncludeLoc()); + SourceLocation IncludeLoc = SourceMgr.getPresumedLoc(Loc).getIncludeLoc(); + if (IncludeLoc.isValid()) + MoveToLine(IncludeLoc); } else if (Reason == PPCallbacks::SystemHeaderPragma) { MoveToLine(Loc);