]> granicus.if.org Git - clang/commitdiff
On Darwin, libc++ may be installed alongside the compiler in
authorDouglas Gregor <dgregor@apple.com>
Fri, 29 Jul 2011 20:21:18 +0000 (20:21 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 29 Jul 2011 20:21:18 +0000 (20:21 +0000)
lib/c++/v1. Look there first, before falling back to the normal
/usr/include/c++/v1. <rdar://problem/9866149>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136507 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/InitHeaderSearch.cpp

index f596b992f5468cc92440e64754dc298c25d03c09..61cc223b3fbf8dd49d9b4bf4050a8b6a94656d8d 100644 (file)
@@ -940,8 +940,24 @@ void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang,
                                                     const llvm::Triple &triple,
                                             const HeaderSearchOptions &HSOpts) {
   if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes) {
-    if (HSOpts.UseLibcxx)
+    if (HSOpts.UseLibcxx) {
+      if (triple.isOSDarwin()) {
+        // On Darwin, libc++ may be installed alongside the compiler in
+        // lib/c++/v1.
+        llvm::sys::Path P(HSOpts.ResourceDir);
+        if (!P.isEmpty()) {
+          P.eraseComponent();  // Remove version from foo/lib/clang/version
+          P.eraseComponent();  // Remove clang from foo/lib/clang
+          
+          // Get foo/lib/c++/v1
+          P.appendComponent("c++");
+          P.appendComponent("v1");
+          AddPath(P.str(), CXXSystem, true, false, false, true);
+        }
+      }
+      
       AddPath("/usr/include/c++/v1", CXXSystem, true, false, false);
+    }
     else
       AddDefaultCPlusPlusIncludePaths(triple, HSOpts);
   }