diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-04-14 04:28:50 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-04-14 04:28:50 +0000 |
| commit | c745cec17c8881f072a4a7aad7ffe27f6197c631 (patch) | |
| tree | 11432d57fb14d2213db1ebbb254c126dfe6cbb73 | |
| parent | 851002d42e92f1560e4b670f4ace036391131265 (diff) | |
| download | bcm5719-llvm-c745cec17c8881f072a4a7aad7ffe27f6197c631.tar.gz bcm5719-llvm-c745cec17c8881f072a4a7aad7ffe27f6197c631.zip | |
Improve line marker directive locations, patch by Jordy Rose
llvm-svn: 101226
| -rw-r--r-- | clang/lib/Frontend/PrintPreprocessedOutput.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 5 | ||||
| -rw-r--r-- | clang/test/Preprocessor/line-directive-output.c | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index b4718e9ad49..b45188f3310 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -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(); diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 757ba9014df..8033e475c8c 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -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); } } diff --git a/clang/test/Preprocessor/line-directive-output.c b/clang/test/Preprocessor/line-directive-output.c index fc1a310bf0b..290703a50e3 100644 --- a/clang/test/Preprocessor/line-directive-output.c +++ b/clang/test/Preprocessor/line-directive-output.c @@ -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" |

