On Darwin, libc++ may be installed alongside the compiler in
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
diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp
index f596b99..61cc223 100644
--- a/lib/Frontend/InitHeaderSearch.cpp
+++ b/lib/Frontend/InitHeaderSearch.cpp
@@ -940,8 +940,24 @@
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);
}