]> granicus.if.org Git - clang/commitdiff
avoid emitting a bogus line marker for the top level #include
authorChris Lattner <sabre@nondot.org>
Fri, 30 Jan 2009 18:44:17 +0000 (18:44 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 30 Jan 2009 18:44:17 +0000 (18:44 +0000)
location.  We now -E a file containing "foo" into:

# 1 "t.c"
# 1 "t.c" 1
# 1 "<predefines>" 1
# 1 "t.c" 2
foo

instead of:

# 1 "t.c"
# 1 "t.c" 1
# 0 "t.c"
# 1 "<predefines>" 1
# 1 "t.c" 2
foo

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63405 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/PrintPreprocessedOutput.cpp

index 5c4a140fa9ae8fe7e4140970d752f4259de55b4f..2c764ade008ddf1482ba195a2c7e0be34f541cbd 100644 (file)
@@ -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);