diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-07-30 06:28:34 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-07-30 06:28:34 +0000 |
commit | 2c7b7803182d1796225bf420d17b216bd81f75b0 (patch) | |
tree | ea508acadd25115d37970fbb427b91cfd55b7aaa /lib/Lex/HeaderSearch.cpp | |
parent | a3f61ae2c824d3999d77efb46f2f996f86885d20 (diff) |
Use the "Bar.h" -> <Foo/Bar.h> remapping for index header maps only as
a fallback, if normal header search fails. Another attempt at
<rdar://problem/9824020>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136557 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/HeaderSearch.cpp')
-rw-r--r-- | lib/Lex/HeaderSearch.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp index 2592ada676..0ba7632742 100644 --- a/lib/Lex/HeaderSearch.cpp +++ b/lib/Lex/HeaderSearch.cpp @@ -280,22 +280,6 @@ const FileEntry *HeaderSearch::LookupFile( return FileMgr.getFile(Filename, /*openFile=*/true); } - // If we are including a file with a quoted include "foo.h" from inside - // a header in a framework that is currently being built, change the include - // to <Foo/foo.h>, where "Foo" is the name of the framework in which the - // including header was found. - llvm::SmallString<128> ScratchFilename; - if (CurFileEnt && !isAngled && Filename.find('/') == StringRef::npos) { - HeaderFileInfo &IncludingHFI = getFileInfo(CurFileEnt); - if (IncludingHFI.IndexHeaderMapHeader) { - isAngled = true; - ScratchFilename += IncludingHFI.Framework; - ScratchFilename += '/'; - ScratchFilename += Filename; - Filename = ScratchFilename; - } - } - // Unless disabled, check to see if the file is in the #includer's // directory. This has to be based on CurFileEnt, not CurDir, because // CurFileEnt could be a #include of a subdirectory (#include "foo/bar.h") and @@ -388,6 +372,29 @@ const FileEntry *HeaderSearch::LookupFile( return FE; } + // If we are including a file with a quoted include "foo.h" from inside + // a header in a framework that is currently being built, and we couldn't + // resolve "foo.h" any other way, change the include to <Foo/foo.h>, where + // "Foo" is the name of the framework in which the including header was found. + if (CurFileEnt && !isAngled && Filename.find('/') == StringRef::npos) { + HeaderFileInfo &IncludingHFI = getFileInfo(CurFileEnt); + if (IncludingHFI.IndexHeaderMapHeader) { + llvm::SmallString<128> ScratchFilename; + ScratchFilename += IncludingHFI.Framework; + ScratchFilename += '/'; + ScratchFilename += Filename; + + const FileEntry *Result = LookupFile(ScratchFilename, /*isAngled=*/true, + FromDir, CurDir, CurFileEnt, + SearchPath, RelativePath); + std::pair<unsigned, unsigned> &CacheLookup + = LookupFileCache.GetOrCreateValue(Filename).getValue(); + CacheLookup.second + = LookupFileCache.GetOrCreateValue(ScratchFilename).getValue().second; + return Result; + } + } + // Otherwise, didn't find it. Remember we didn't find this. CacheLookup.second = SearchDirs.size(); return 0; |