diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-11-19 21:57:25 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-11-19 21:57:25 +0000 |
commit | 41938c8493b4380df738263166b746eacb33c309 (patch) | |
tree | 022e9ebc4fce4341598c81f1242256cd79830325 /include | |
parent | cda658e90d7ffe0ece23d741ff82cf764108f66c (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 'include')
-rw-r--r-- | include/clang/Lex/Preprocessor.h | 20 | ||||
-rw-r--r-- | include/clang/Lex/PreprocessorLexer.h | 14 |
2 files changed, 32 insertions, 2 deletions
diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 4d31be4ecf..d803cb6a97 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -608,7 +608,25 @@ private: const FileEntry *LookupFile(const char *FilenameStart,const char *FilenameEnd, bool isAngled, const DirectoryLookup *FromDir, const DirectoryLookup *&CurDir); - + + + + static bool IsNonPragmaNonMacroLexer(const Lexer* L, + const PreprocessorLexer* P) { + if (L) + return !L->isPragmaLexer(); + else + return P != 0; + } + + static bool IsNonPragmaNonMacroLexer(const IncludeStackInfo& I) { + return IsNonPragmaNonMacroLexer(I.TheLexer, I.ThePPLexer); + } + + bool IsNonPragmaNonMacroLexer() const { + return IsNonPragmaNonMacroLexer(CurLexer.get(), CurPPLexer); + } + //===--------------------------------------------------------------------===// // Caching stuff. void CachingLex(Token &Result); diff --git a/include/clang/Lex/PreprocessorLexer.h b/include/clang/Lex/PreprocessorLexer.h index de9c6b780a..df8049e214 100644 --- a/include/clang/Lex/PreprocessorLexer.h +++ b/include/clang/Lex/PreprocessorLexer.h @@ -26,6 +26,9 @@ class Preprocessor; class PreprocessorLexer { protected: Preprocessor *PP; // Preprocessor object controlling lexing. + + /// The SourceManager fileID corresponding to the file being lexed. + const unsigned FileID; //===--------------------------------------------------------------------===// // Context-specific lexing flags set by the preprocessor. @@ -64,7 +67,9 @@ protected: void operator=(const PreprocessorLexer&); // DO NOT IMPLEMENT friend class Preprocessor; - PreprocessorLexer(Preprocessor* pp) : PP(pp) {} + PreprocessorLexer(Preprocessor* pp, SourceLocation L); + PreprocessorLexer() : PP(0), FileID(0) {} + virtual ~PreprocessorLexer(); virtual void IndirectLex(Token& Result) = 0; @@ -119,6 +124,13 @@ protected: /// (potentially) macro expand the filename. If the sequence parsed is not /// lexically legal, emit a diagnostic and return a result EOM token. void LexIncludeFilename(Token &Result); + +public: + unsigned getFileID() const { + assert(PP && + "PreprocessorLexer::getFileID() should only be used with a Preprocessor"); + return FileID; + } }; } // end namespace clang |