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 | 2df37b8eaecc5382e0e511a738f88918f48d9454 (patch) | |
tree | c172a8a5006d58589bd8ffa5b655bfeb1bf40f33 /lib/Lex/PPLexerChange.cpp | |
parent | 92548fed40519a09a1c016ceb6ab078384ab5ebc (diff) |
Revert 59574 (caused tests to fail).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59579 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPLexerChange.cpp')
-rw-r--r-- | lib/Lex/PPLexerChange.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/Lex/PPLexerChange.cpp b/lib/Lex/PPLexerChange.cpp index c16abf4313..87330983d6 100644 --- a/lib/Lex/PPLexerChange.cpp +++ b/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); |