diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-04-17 19:09:18 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-04-17 19:09:18 +0000 |
commit | 111c4a6b69086773254345c7edd2ce4f439c98d9 (patch) | |
tree | 4598e6c97d48aa475bc29015d689ef2ba7b263fc /clang/lib/Frontend/PrintPreprocessedOutput.cpp | |
parent | 3c626edda24ffa583ba5ecb30cabd4af37bbbd35 (diff) | |
download | bcm5719-llvm-111c4a6b69086773254345c7edd2ce4f439c98d9.tar.gz bcm5719-llvm-111c4a6b69086773254345c7edd2ce4f439c98d9.zip |
Fix off-by-one error in #pragma clang system_header.
The system_header pragma (from GCC) is implemented using line notes in the
source manager. However, a line note's line number specifies the number
not for the current line, but for the next line. This was making all
line numbers appear off by one after the pragma.
Reported by Andy Gibbs, uncovered during r179677.
llvm-svn: 179709
Diffstat (limited to 'clang/lib/Frontend/PrintPreprocessedOutput.cpp')
-rw-r--r-- | clang/lib/Frontend/PrintPreprocessedOutput.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index 180c1774446..61f2b9e2884 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -270,11 +270,12 @@ void PrintPPOutputPPCallbacks::FileChanged(SourceLocation Loc, if (IncludeLoc.isValid()) MoveToLine(IncludeLoc); } else if (Reason == PPCallbacks::SystemHeaderPragma) { - MoveToLine(NewLine); - - // TODO GCC emits the # directive for this directive on the line AFTER the - // directive and emits a bunch of spaces that aren't needed. Emulate this - // strange behavior. + // GCC emits the # directive for this directive on the line AFTER the + // directive and emits a bunch of spaces that aren't needed. This is because + // otherwise we will emit a line marker for THIS line, which requires an + // extra blank line after the directive to avoid making all following lines + // off by one. We can do better by simply incrementing NewLine here. + NewLine += 1; } CurLine = NewLine; |