Improve line marker directive locations, patch by Jordy Rose

llvm-svn: 101226
This commit is contained in:
Chris Lattner 2010-04-14 04:28:50 +00:00
parent 851002d42e
commit c745cec17c
3 changed files with 5 additions and 4 deletions

View 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();

View 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);
}
}

View 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"