[cfe-commits] r164774 - /cfe/trunk/lib/Lex/ModuleMap.cpp

Douglas Gregor dgregor at apple.com
Thu Sep 27 07:50:16 PDT 2012


Author: dgregor
Date: Thu Sep 27 09:50:15 2012
New Revision: 164774

URL: http://llvm.org/viewvc/llvm-project?rev=164774&view=rev
Log:
Following up on r164620, cope with symlinking from an embedded
framework location out to a top-level framework. Such frameworks are
not really embedded at all.

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

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=164774&r1=164773&r2=164774&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Thu Sep 27 09:50:15 2012
@@ -26,6 +26,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
+#include <stdlib.h>
 using namespace clang;
 
 Module::ExportDecl 
@@ -343,9 +344,37 @@
        Dir != DirEnd && !EC; Dir.increment(EC)) {
     if (!StringRef(Dir->path()).endswith(".framework"))
       continue;
-    
+
     if (const DirectoryEntry *SubframeworkDir
           = FileMgr.getDirectory(Dir->path())) {
+      // Note: as an egregious but useful hack, we use the real path here and
+      // check whether it is actually a subdirectory of the parent directory.
+      // This will not be the case if the 'subframework' is actually a symlink
+      // out to a top-level framework.
+#ifdef LLVM_ON_UNIX
+      char RealSubframeworkDirName[PATH_MAX];
+      if (realpath(Dir->path().c_str(), RealSubframeworkDirName)) {
+        StringRef SubframeworkDirName = RealSubframeworkDirName;
+
+        bool FoundParent = false;
+        do {
+          // Get the parent directory name.
+          SubframeworkDirName
+            = llvm::sys::path::parent_path(SubframeworkDirName);
+          if (SubframeworkDirName.empty())
+            break;
+
+          if (FileMgr.getDirectory(SubframeworkDirName) == FrameworkDir) {
+            FoundParent = true;
+            break;
+          }
+        } while (true);
+
+        if (!FoundParent)
+          continue;
+      }
+#endif
+
       // FIXME: Do we want to warn about subframeworks without umbrella headers?
       inferFrameworkModule(llvm::sys::path::stem(Dir->path()), SubframeworkDir,
                            IsSystem, Result);





More information about the cfe-commits mailing list