]> granicus.if.org Git - clang/commitdiff
Improve line marker directive locations, patch by Jordy Rose
authorChris Lattner <sabre@nondot.org>
Wed, 14 Apr 2010 04:28:50 +0000 (04:28 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 14 Apr 2010 04:28:50 +0000 (04:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101226 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/PrintPreprocessedOutput.cpp
lib/Lex/PPDirectives.cpp
test/Preprocessor/line-directive-output.c

index b4718e9ad499cabf8a37c0eff571c381cb38bfd7..b45188f3310f8a26fb2a10e330aa301d437ee07e 100644 (file)
@@ -219,7 +219,7 @@ void PrintPPOutputPPCallbacks::FileChanged(SourceLocation Loc,
   SourceManager &SourceMgr = SM;
   
   PresumedLoc UserLoc = SourceMgr.getPresumedLoc(Loc);
-  unsigned NewLine = UserLoc.getLine()+1;
+  unsigned NewLine = UserLoc.getLine();
   
   if (Reason == PPCallbacks::EnterFile) {
     SourceLocation IncludeLoc = SourceMgr.getPresumedLoc(Loc).getIncludeLoc();
index 757ba9014df602f1c6520bb9cde485cab3644082..8033e475c8c447f9dd156b9c2ae5de04005ad71d 100644 (file)
@@ -716,7 +716,8 @@ void Preprocessor::HandleLineDirective(Token &Tok) {
   SourceMgr.AddLineNote(DigitTok.getLocation(), LineNo, FilenameID);
 
   if (Callbacks)
-    Callbacks->FileChanged(DigitTok.getLocation(), PPCallbacks::RenameFile,
+    Callbacks->FileChanged(CurPPLexer->getSourceLocation(),
+                           PPCallbacks::RenameFile,
                            SrcMgr::C_User);
 }
 
@@ -865,7 +866,7 @@ void Preprocessor::HandleDigitDirective(Token &DigitTok) {
     else if (IsSystemHeader)
       FileKind = SrcMgr::C_System;
 
-    Callbacks->FileChanged(DigitTok.getLocation(), Reason, FileKind);
+    Callbacks->FileChanged(CurPPLexer->getSourceLocation(), Reason, FileKind);
   }
 }
 
index fc1a310bf0bdc492ef070e97be47bb5ae1352635..290703a50e3bae3653d3e120349baf9e2e4608f7 100644 (file)
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -E %s 2>&1 | FileCheck %s -strict-whitespace
 // PR6101
 int a;
-// CHECK: # 2 "{{.*}}line-directive-output.c"
+// CHECK: # 1 "{{.*}}line-directive-output.c"
 // CHECK: int a;
 
 // CHECK-NEXT: # 50 "{{.*}}line-directive-output.c"