aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/PPLexerChange.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-11-19 21:57:25 +0000
committerTed Kremenek <kremenek@apple.com>2008-11-19 21:57:25 +0000
commit41938c8493b4380df738263166b746eacb33c309 (patch)
tree022e9ebc4fce4341598c81f1242256cd79830325 /lib/Lex/PPLexerChange.cpp
parentcda658e90d7ffe0ece23d741ff82cf764108f66c (diff)
- Move static function IsNonPragmaNonMacroLexer into Preprocessor.h.
- Add variants of IsNonPragmaNonMacroLexer to accept an IncludeMacroStack entry (simplifies some uses). - Use IsNonPragmaNonMacroLexer in Preprocessor::LookupFile. - Add 'FileID' to PreprocessorLexer, and have Preprocessor query this fileid when looking up the FileEntry for a file Performance testing of -Eonly on Cocoa.h shows no performance regression because of this patch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59666 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPLexerChange.cpp')
-rw-r--r--lib/Lex/PPLexerChange.cpp19
1 files changed, 5 insertions, 14 deletions
diff --git a/lib/Lex/PPLexerChange.cpp b/lib/Lex/PPLexerChange.cpp
index 87330983d6..3a2ed658fb 100644
--- a/lib/Lex/PPLexerChange.cpp
+++ b/lib/Lex/PPLexerChange.cpp
@@ -25,27 +25,17 @@ 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 +81,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);
@@ -212,6 +202,7 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
// We're done with the #included file.
CurLexer.reset();
+ CurPPLexer = 0;
// This is the end of the top-level file. If the diag::pp_macro_not_used
// diagnostic is enabled, look for macros that have not been used.