[cfe-commits] r136557 - /cfe/trunk/lib/Lex/HeaderSearch.cpp

Douglas Gregor dgregor at apple.com
Fri Jul 29 23:28:34 PDT 2011


Author: dgregor
Date: Sat Jul 30 01:28:34 2011
New Revision: 136557

URL: http://llvm.org/viewvc/llvm-project?rev=136557&view=rev
Log:
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>.

Modified:
    cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=136557&r1=136556&r2=136557&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Sat Jul 30 01:28:34 2011
@@ -280,22 +280,6 @@
     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 @@
     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;





More information about the cfe-commits mailing list