aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/HeaderSearch.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-07-28 04:45:53 +0000
committerDouglas Gregor <dgregor@apple.com>2011-07-28 04:45:53 +0000
commit65e02fa80e1c185f18e5f81cefc30d75383a7301 (patch)
tree244ea3b8ba968fde89e9bcfe015c8e6ab93ea601 /lib/Lex/HeaderSearch.cpp
parente1adf8177fcd2e571ea2183c20160ab829cb88c8 (diff)
Introduce the "-index-header-map" option, to give special semantics
for quoted header lookup when dealing with not-yet-installed frameworks. Fixes <rdar://problem/9824020>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136331 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/HeaderSearch.cpp')
-rw-r--r--lib/Lex/HeaderSearch.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp
index 11cb1ecd8c..2592ada676 100644
--- a/lib/Lex/HeaderSearch.cpp
+++ b/lib/Lex/HeaderSearch.cpp
@@ -280,7 +280,23 @@ const FileEntry *HeaderSearch::LookupFile(
return FileMgr.getFile(Filename, /*openFile=*/true);
}
- // Step #0, unless disabled, check to see if the file is in the #includer's
+ // 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
// a subsequent include of "baz.h" should resolve to "whatever/foo/baz.h".
@@ -353,8 +369,20 @@ const FileEntry *HeaderSearch::LookupFile(
CurDir = &SearchDirs[i];
// This file is a system header or C++ unfriendly if the dir is.
- getFileInfo(FE).DirInfo = CurDir->getDirCharacteristic();
-
+ HeaderFileInfo &HFI = getFileInfo(FE);
+ HFI.DirInfo = CurDir->getDirCharacteristic();
+
+ // If this file is found in a header map and uses the framework style of
+ // includes, then this header is part of a framework we're building.
+ if (CurDir->isIndexHeaderMap()) {
+ size_t SlashPos = Filename.find('/');
+ if (SlashPos != StringRef::npos) {
+ HFI.IndexHeaderMapHeader = 1;
+ HFI.Framework = getUniqueFrameworkName(StringRef(Filename.begin(),
+ SlashPos));
+ }
+ }
+
// Remember this location for the next lookup we do.
CacheLookup.second = i;
return FE;
@@ -550,3 +578,7 @@ size_t HeaderSearch::getTotalMemory() const {
+ LookupFileCache.getAllocator().getTotalMemory()
+ FrameworkMap.getAllocator().getTotalMemory();
}
+
+StringRef HeaderSearch::getUniqueFrameworkName(StringRef Framework) {
+ return FrameworkNames.GetOrCreateValue(Framework).getKey();
+}