summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-02-13 19:33:24 +0000
committerChris Lattner <sabre@nondot.org>2009-02-13 19:33:24 +0000
commit9ef847be12cfdb9a20885be4c77dacd2439bc4c3 (patch)
tree73e032930d4ac15c7d909aeecb1e6b375de2aba9 /clang/lib/Lex/Preprocessor.cpp
parent7ab278db061ab8f5e702b6c7ce7061ea4c6fb5fb (diff)
downloadbcm5719-llvm-9ef847be12cfdb9a20885be4c77dacd2439bc4c3.tar.gz
bcm5719-llvm-9ef847be12cfdb9a20885be4c77dacd2439bc4c3.zip
Fix rdar://6562329, a static analyzer crash Ted noticed on
wine sources. This was happening because HighlightMacros was calling EnterMainFile multiple times on the same preprocessor object and getting an assert due to the new #line stuff (the file in question was bison output with #line directives). The fix for this is to not reenter the file. Instead, relex the tokens in raw mode, swizzle them a bit and repreprocess the token stream. An added bonus of this is that rewrite macros will now hilight the macro definition as well as its uses. Woo. llvm-svn: 64480
Diffstat (limited to 'clang/lib/Lex/Preprocessor.cpp')
-rw-r--r--clang/lib/Lex/Preprocessor.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index 69aa7cb51a6..f16d83c5a2e 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -626,7 +626,10 @@ static void InitializePredefinedMacros(Preprocessor &PP,
/// EnterMainSourceFile - Enter the specified FileID as the main source file,
/// which implicitly adds the builtin defines etc.
void Preprocessor::EnterMainSourceFile() {
-
+ // We do not allow the preprocessor to reenter the main file. Doing so will
+ // cause FileID's to accumulate information from both runs (e.g. #line
+ // information) and predefined macros aren't guaranteed to be set properly.
+ assert(NumEnteredSourceFiles == 0 && "Cannot reenter the main file!");
FileID MainFileID = SourceMgr.getMainFileID();
// Enter the main file source buffer.
OpenPOWER on IntegriCloud