[cfe-commits] r67854 - in /cfe/trunk: lib/Lex/PPDirectives.cpp tools/clang-cc/PrintPreprocessedOutput.cpp
Chris Lattner
sabre at nondot.org
Fri Mar 27 10:13:55 PDT 2009
Author: lattner
Date: Fri Mar 27 12:13:49 2009
New Revision: 67854
URL: http://llvm.org/viewvc/llvm-project?rev=67854&view=rev
Log:
push line markers through -E mode.
Modified:
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/tools/clang-cc/PrintPreprocessedOutput.cpp
Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=67854&r1=67853&r2=67854&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Fri Mar 27 12:13:49 2009
@@ -692,6 +692,10 @@
}
SourceMgr.AddLineNote(DigitTok.getLocation(), LineNo, FilenameID);
+
+ if (Callbacks)
+ Callbacks->FileChanged(DigitTok.getLocation(), PPCallbacks::RenameFile,
+ SrcMgr::C_User);
}
/// ReadLineMarkerFlags - Parse and validate any flags at the end of a GNU line
@@ -823,6 +827,24 @@
SourceMgr.AddLineNote(DigitTok.getLocation(), LineNo, FilenameID,
IsFileEntry, IsFileExit,
IsSystemHeader, IsExternCHeader);
+
+ // If the preprocessor has callbacks installed, notify them of the #line
+ // change. This is used so that the line marker comes out in -E mode for
+ // example.
+ if (Callbacks) {
+ PPCallbacks::FileChangeReason Reason = PPCallbacks::RenameFile;
+ if (IsFileEntry)
+ Reason = PPCallbacks::EnterFile;
+ else if (IsFileExit)
+ Reason = PPCallbacks::ExitFile;
+ SrcMgr::CharacteristicKind FileKind = SrcMgr::C_User;
+ if (IsExternCHeader)
+ FileKind = SrcMgr::C_ExternCSystem;
+ else if (IsSystemHeader)
+ FileKind = SrcMgr::C_System;
+
+ Callbacks->FileChanged(DigitTok.getLocation(), Reason, FileKind);
+ }
}
Modified: cfe/trunk/tools/clang-cc/PrintPreprocessedOutput.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/PrintPreprocessedOutput.cpp?rev=67854&r1=67853&r2=67854&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/tools/clang-cc/PrintPreprocessedOutput.cpp Fri Mar 27 12:13:49 2009
@@ -172,6 +172,7 @@
}
Loc = SourceMgr.getInstantiationLoc(Loc);
+ // FIXME: Should use presumed line #!
CurLine = SourceMgr.getInstantiationLineNumber(Loc);
if (DisableLineMarkers) return;
More information about the cfe-commits
mailing list