diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-11-19 01:54:47 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-11-19 01:54:47 +0000 |
commit | a7c279ba409061337b7caf3a7e6cd233e9bbb24d (patch) | |
tree | 956e89ce28ae8ca51c0e3366ee974a2cbe6e1e5a /clang/lib/Lex/PPLexerChange.cpp | |
parent | 5a205a57d88d1c7a0d9341c91f1d94c004633d9b (diff) | |
download | bcm5719-llvm-a7c279ba409061337b7caf3a7e6cd233e9bbb24d.tar.gz bcm5719-llvm-a7c279ba409061337b7caf3a7e6cd233e9bbb24d.zip |
Revert 59574 (caused tests to fail).
llvm-svn: 59579
Diffstat (limited to 'clang/lib/Lex/PPLexerChange.cpp')
-rw-r--r-- | clang/lib/Lex/PPLexerChange.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp index c16abf43130..87330983d65 100644 --- a/clang/lib/Lex/PPLexerChange.cpp +++ b/clang/lib/Lex/PPLexerChange.cpp @@ -25,19 +25,28 @@ PPCallbacks::~PPCallbacks() {} // Miscellaneous Methods. //===----------------------------------------------------------------------===// +static inline bool IsNonPragmaNonMacroLexer(const Lexer* L, + const PreprocessorLexer* P) { + if (L) + return !L->isPragmaLexer(); + else + return P != 0; +} + /// isInPrimaryFile - Return true if we're in the top-level file, not in a /// #include. This looks through macro expansions and active _Pragma lexers. bool Preprocessor::isInPrimaryFile() const { - if (IsNonPragmaNonMacroLexer()) + if (IsNonPragmaNonMacroLexer(CurLexer.get(), CurPPLexer)) return IncludeMacroStack.empty(); // If there are any stacked lexers, we're in a #include. - assert(IsNonPragmaNonMacroLexer(IncludeMacroStack[0]) && + assert(IsNonPragmaNonMacroLexer(IncludeMacroStack[0].TheLexer, + IncludeMacroStack[0].ThePPLexer) && "Top level include stack isn't our primary lexer?"); for (unsigned i = 1, e = IncludeMacroStack.size(); i != e; ++i) - if (IsNonPragmaNonMacroLexer(IncludeMacroStack[i])) + if (IsNonPragmaNonMacroLexer(IncludeMacroStack[i].TheLexer, + IncludeMacroStack[i].ThePPLexer)) return false; - return true; } @@ -82,7 +91,7 @@ void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer, const DirectoryLookup *CurDir) { // Add the current lexer to the include stack. - if (CurPPLexer || CurTokenLexer) + if (CurLexer || CurTokenLexer) PushIncludeMacroStack(); CurLexer.reset(TheLexer); |