diff options
author | Daniel Dunbar <daniel@zuster.org> | 2012-11-16 01:51:11 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2012-11-16 01:51:11 +0000 |
commit | 5d38875d8173367f224570ec2b03a30e656ed60b (patch) | |
tree | 34ae155be32832d1f8a940883a9ea372b1370002 /clang/lib/Frontend/PrintPreprocessedOutput.cpp | |
parent | 08b5fef122e899179c12c05792cd48dc36e2d319 (diff) | |
download | llvm-5d38875d8173367f224570ec2b03a30e656ed60b.zip llvm-5d38875d8173367f224570ec2b03a30e656ed60b.tar.gz llvm-5d38875d8173367f224570ec2b03a30e656ed60b.tar.bz2 |
CPP Output: Do not emit an enter file marker for the main file.
- This diverges from gcc, and confuses tools (like dtrace) which track # line
markers as a way to determine which content is in the context of the main
file.
llvm-svn: 168128
Diffstat (limited to 'clang/lib/Frontend/PrintPreprocessedOutput.cpp')
-rw-r--r-- | clang/lib/Frontend/PrintPreprocessedOutput.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index 30707dc..0dc9281 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -95,6 +95,7 @@ private: bool DisableLineMarkers; bool DumpDefines; bool UseLineDirective; + bool IsFirstFileEntered; public: PrintPPOutputPPCallbacks(Preprocessor &pp, raw_ostream &os, bool lineMarkers, bool defines) @@ -107,6 +108,7 @@ public: EmittedDirectiveOnThisLine = false; FileType = SrcMgr::C_User; Initialized = false; + IsFirstFileEntered = false; // If we're in microsoft mode, use normal #line instead of line markers. UseLineDirective = PP.getLangOpts().MicrosoftExt; @@ -273,6 +275,15 @@ void PrintPPOutputPPCallbacks::FileChanged(SourceLocation Loc, Initialized = true; } + // Do not emit an enter marker for the main file (which we expect is the first + // entered file). This matches gcc, and improves compatibility with some tools + // which track the # line markers as a way to determine when the preprocessed + // output is in the context of the main file. + if (Reason == PPCallbacks::EnterFile && !IsFirstFileEntered) { + IsFirstFileEntered = true; + return; + } + switch (Reason) { case PPCallbacks::EnterFile: WriteLineInfo(CurLine, " 1", 2); |