aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/PrintPreprocessedOutput.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2012-11-16 01:51:11 +0000
committerDaniel Dunbar <daniel@zuster.org>2012-11-16 01:51:11 +0000
commit2a9be3e5b0c390f9189bb3dec2b2b6ba884f60cc (patch)
tree12b67ec0f6bd38d43c61141c552e31d940d04b17 /lib/Frontend/PrintPreprocessedOutput.cpp
parent8f50b24c8b17368f68c2e71240d487dde53f6da8 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168128 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PrintPreprocessedOutput.cpp')
-rw-r--r--lib/Frontend/PrintPreprocessedOutput.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp
index 30707dc0c0..0dc9281166 100644
--- a/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/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);