diff options
author | Ilya Biryukov <ibiryukov@google.com> | 2018-11-12 13:55:55 +0000 |
---|---|---|
committer | Ilya Biryukov <ibiryukov@google.com> | 2018-11-12 13:55:55 +0000 |
commit | d8ebe7951d30874d31a11baa8502cd09d100136d (patch) | |
tree | 4c72bc518f910337f9c92e989ec638be7996d792 /clang/lib/Frontend/CreateInvocationFromCommandLine.cpp | |
parent | 87ab8f316f8f226c0f13fbc3252b0bb6a7efbefc (diff) | |
download | llvm-d8ebe7951d30874d31a11baa8502cd09d100136d.zip llvm-d8ebe7951d30874d31a11baa8502cd09d100136d.tar.gz llvm-d8ebe7951d30874d31a11baa8502cd09d100136d.tar.bz2 |
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/CreateInvocationFromCommandLine.cpp')
-rw-r--r-- | clang/lib/Frontend/CreateInvocationFromCommandLine.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp index 2d4c40f..3a5e1e8 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; } |