aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/PPDirectives.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-02-04 19:45:07 +0000
committerChris Lattner <sabre@nondot.org>2009-02-04 19:45:07 +0000
commitbe5c64d7a765acaf9454e7a511233771472bf811 (patch)
treef6981a7c372099bf01e3add147af7135970261f4 /lib/Lex/PPDirectives.cpp
parentd62ef1a951d586241e86f300d3321b3f04c2275c (diff)
Fix PR3464 by searching for headers from the predefines
buffer as if the #include happened from the main file. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63764 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPDirectives.cpp')
-rw-r--r--lib/Lex/PPDirectives.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index 00cb62384e..c38310b925 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -399,13 +399,24 @@ const FileEntry *Preprocessor::LookupFile(const char *FilenameStart,
if (!FromDir) {
FileID FID = getCurrentFileLexer()->getFileID();
CurFileEnt = SourceMgr.getFileEntryForID(FID);
+
+ // If there is no file entry associated with this file, it must be the
+ // predefines buffer. Any other file is not lexed with a normal lexer, so
+ // it won't be scanned for preprocessor directives. If we have the
+ // predefines buffer, resolve #include references (which come from the
+ // -include command line argument) as if they came from the main file, this
+ // affects file lookup etc.
+ if (CurFileEnt == 0) {
+ FID = SourceMgr.getMainFileID();
+ CurFileEnt = SourceMgr.getFileEntryForID(FID);
+ }
}
// Do a standard file entry lookup.
CurDir = CurDirLookup;
const FileEntry *FE =
- HeaderInfo.LookupFile(FilenameStart, FilenameEnd,
- isAngled, FromDir, CurDir, CurFileEnt);
+ HeaderInfo.LookupFile(FilenameStart, FilenameEnd,
+ isAngled, FromDir, CurDir, CurFileEnt);
if (FE) return FE;
// Otherwise, see if this is a subframework header. If so, this is relative