- 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
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index ced7673..a1216b1 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -303,8 +303,8 @@
// info about where the current file is.
const FileEntry *CurFileEnt = 0;
if (!FromDir) {
- SourceLocation FileLoc = getCurrentFileLexer()->getFileLoc();
- CurFileEnt = SourceMgr.getFileEntryForLoc(FileLoc);
+ unsigned FileID = getCurrentFileLexer()->getFileID();
+ CurFileEnt = SourceMgr.getFileEntryForID(FileID);
}
// Do a standard file entry lookup.
@@ -317,8 +317,8 @@
// Otherwise, see if this is a subframework header. If so, this is relative
// to one of the headers on the #include stack. Walk the list of the current
// headers on the #include stack and pass them to HeaderInfo.
- if (CurLexer && !CurLexer->Is_PragmaLexer) {
- if ((CurFileEnt = SourceMgr.getFileEntryForLoc(CurLexer->getFileLoc())))
+ if (IsNonPragmaNonMacroLexer()) {
+ if ((CurFileEnt = SourceMgr.getFileEntryForID(CurPPLexer->getFileID())))
if ((FE = HeaderInfo.LookupSubframeworkHeader(FilenameStart, FilenameEnd,
CurFileEnt)))
return FE;
@@ -326,9 +326,9 @@
for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) {
IncludeStackInfo &ISEntry = IncludeMacroStack[e-i-1];
- if (ISEntry.TheLexer && !ISEntry.TheLexer->Is_PragmaLexer) {
+ if (IsNonPragmaNonMacroLexer(ISEntry)) {
if ((CurFileEnt =
- SourceMgr.getFileEntryForLoc(ISEntry.TheLexer->getFileLoc())))
+ SourceMgr.getFileEntryForID(ISEntry.ThePPLexer->getFileID())))
if ((FE = HeaderInfo.LookupSubframeworkHeader(FilenameStart,
FilenameEnd, CurFileEnt)))
return FE;