summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r--clang/lib/Frontend/CreateInvocationFromCommandLine.cpp8
-rw-r--r--clang/lib/Frontend/InitHeaderSearch.cpp11
2 files changed, 9 insertions, 10 deletions
diff --git a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
index 2d4c40f8b9f..3a5e1e8b15e 100644
--- a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -11,17 +11,18 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/Frontend/Utils.h"
#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Driver/Action.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
-#include "clang/Driver/Action.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/Tool.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendDiagnostic.h"
+#include "clang/Frontend/Utils.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/Host.h"
+#include "llvm/Support/Path.h"
using namespace clang;
using namespace llvm::opt;
@@ -102,5 +103,8 @@ std::unique_ptr<CompilerInvocation> clang::createInvocationFromCommandLine(
CCArgs.size(),
*Diags))
return nullptr;
+ // Patch up the install dir, so we find the same standard library as the
+ // original compiler on MacOS.
+ CI->getHeaderSearchOpts().InstallDir = TheDriver.getInstalledDir();
return CI;
}
diff --git a/clang/lib/Frontend/InitHeaderSearch.cpp b/clang/lib/Frontend/InitHeaderSearch.cpp
index deedb22f3e1..2f62ad3faf6 100644
--- a/clang/lib/Frontend/InitHeaderSearch.cpp
+++ b/clang/lib/Frontend/InitHeaderSearch.cpp
@@ -476,14 +476,9 @@ void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
if (triple.isOSDarwin()) {
// On Darwin, libc++ may be installed alongside the compiler in
// include/c++/v1.
- if (!HSOpts.ResourceDir.empty()) {
- // Remove version from foo/lib/clang/version
- StringRef NoVer = llvm::sys::path::parent_path(HSOpts.ResourceDir);
- // Remove clang from foo/lib/clang
- StringRef Lib = llvm::sys::path::parent_path(NoVer);
- // Remove lib from foo/lib
- SmallString<128> P = llvm::sys::path::parent_path(Lib);
-
+ if (!HSOpts.InstallDir.empty()) {
+ // Get from foo/bin to foo.
+ SmallString<128> P(llvm::sys::path::parent_path(HSOpts.InstallDir));
// Get foo/include/c++/v1
llvm::sys::path::append(P, "include", "c++", "v1");
AddUnmappedPath(P, CXXSystem, false);
OpenPOWER on IntegriCloud