summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/InitHeaderSearch.cpp
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2018-11-12 13:55:55 +0000
committerIlya Biryukov <ibiryukov@google.com>2018-11-12 13:55:55 +0000
commitd8ebe7951d30874d31a11baa8502cd09d100136d (patch)
tree4c72bc518f910337f9c92e989ec638be7996d792 /clang/lib/Frontend/InitHeaderSearch.cpp
parent87ab8f316f8f226c0f13fbc3252b0bb6a7efbefc (diff)
downloadbcm5719-llvm-d8ebe7951d30874d31a11baa8502cd09d100136d.tar.gz
bcm5719-llvm-d8ebe7951d30874d31a11baa8502cd09d100136d.zip
Make clang-based tools find libc++ on MacOS
Summary: When they read compiler args from compile_commands.json. This change allows to run clang-based tools, like clang-tidy or clangd, built from head using the compile_commands.json file produced for XCode toolchains. On MacOS clang can find the C++ standard library relative to the compiler installation dir. The logic to do this was based on resource dir as an approximation of where the compiler is installed. This broke the tools that read 'compile_commands.json' and don't ship with the compiler, as they typically change resource dir. To workaround this, we now use compiler install dir detected by the driver to better mimic the behavior of the original compiler when replaying the compilations using other tools. Reviewers: sammccall, arphaman, EricWF Reviewed By: sammccall Subscribers: ioeric, christof, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54310 llvm-svn: 346652
Diffstat (limited to 'clang/lib/Frontend/InitHeaderSearch.cpp')
-rw-r--r--clang/lib/Frontend/InitHeaderSearch.cpp11
1 files changed, 3 insertions, 8 deletions
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