diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-11-19 00:46:18 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-11-19 00:46:18 +0000 |
commit | 1b167108bbbf206e9d336fa3028d53d38f88adde (patch) | |
tree | 29f1998644e27aa55e1c571e223d691f58b2ca71 /clang/lib/Lex/PPLexerChange.cpp | |
parent | c7a366309d95c60132af664f7903086352d2b5e1 (diff) | |
download | bcm5719-llvm-1b167108bbbf206e9d336fa3028d53d38f88adde.tar.gz bcm5719-llvm-1b167108bbbf206e9d336fa3028d53d38f88adde.zip |
- Move static function IsNonPragmaNonMacroLexer into Preprocessor.h.
- Add variants of IsNonPragmaNonMacroLexer to accept an IncludeMacroStack entry
(simplifies some uses).
- Use IsNonPragmaNonMacroLexer in Preprocessor::LookupFile.
Performance testing of -Eonly on Cocoa.h shows no performance regression because
of this patch.
llvm-svn: 59574
Diffstat (limited to 'clang/lib/Lex/PPLexerChange.cpp')
-rw-r--r-- | clang/lib/Lex/PPLexerChange.cpp | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp index 87330983d65..c16abf43130 100644 --- a/clang/lib/Lex/PPLexerChange.cpp +++ b/clang/lib/Lex/PPLexerChange.cpp @@ -25,28 +25,19 @@ 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(CurLexer.get(), CurPPLexer)) + if (IsNonPragmaNonMacroLexer()) return IncludeMacroStack.empty(); // If there are any stacked lexers, we're in a #include. - assert(IsNonPragmaNonMacroLexer(IncludeMacroStack[0].TheLexer, - IncludeMacroStack[0].ThePPLexer) && + assert(IsNonPragmaNonMacroLexer(IncludeMacroStack[0]) && "Top level include stack isn't our primary lexer?"); for (unsigned i = 1, e = IncludeMacroStack.size(); i != e; ++i) - if (IsNonPragmaNonMacroLexer(IncludeMacroStack[i].TheLexer, - IncludeMacroStack[i].ThePPLexer)) + if (IsNonPragmaNonMacroLexer(IncludeMacroStack[i])) return false; + return true; } @@ -91,7 +82,7 @@ void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer, const DirectoryLookup *CurDir) { // Add the current lexer to the include stack. - if (CurLexer || CurTokenLexer) + if (CurPPLexer || CurTokenLexer) PushIncludeMacroStack(); CurLexer.reset(TheLexer); |