diff options
author | Nico Weber <nicolasweber@gmx.de> | 2019-01-31 22:15:32 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2019-01-31 22:15:32 +0000 |
commit | 0abcafd8a48ddfcf80b41c20810d6f44de58fc24 (patch) | |
tree | 0fab38bb6304df4c9377f5a8808e7e53d5a61926 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 8f6182f7f669f21e90ad7920a7e911f0444c9da9 (diff) | |
download | bcm5719-llvm-0abcafd8a48ddfcf80b41c20810d6f44de58fc24.tar.gz bcm5719-llvm-0abcafd8a48ddfcf80b41c20810d6f44de58fc24.zip |
Make clang/test/Index/pch-from-libclang.c pass in more places
- fixes the test on macOS with LLVM_ENABLE_PIC=OFF
- together with D57343, gets the test to pass on Windows
- makes it run everywhere (it seems to just pass on Linux)
The main change is to pull out the resource directory computation into a
function shared by all 3 places that do it. In CIndexer.cpp, this now works no
matter if libclang is in lib/ or bin/ or statically linked to a binary in bin/.
Differential Revision: https://reviews.llvm.org/D57345
llvm-svn: 352803
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index dbc29e24aee..05cce3c9094 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -26,6 +26,7 @@ #include "clang/Basic/Visibility.h" #include "clang/Basic/XRayInstr.h" #include "clang/Config/config.h" +#include "clang/Driver/Driver.h" #include "clang/Driver/DriverDiagnostic.h" #include "clang/Driver/Options.h" #include "clang/Frontend/CommandLineSourceLoc.h" @@ -1893,18 +1894,7 @@ std::string CompilerInvocation::GetResourcesPath(const char *Argv0, void *MainAddr) { std::string ClangExecutable = llvm::sys::fs::getMainExecutable(Argv0, MainAddr); - StringRef Dir = llvm::sys::path::parent_path(ClangExecutable); - - // Compute the path to the resource directory. - StringRef ClangResourceDir(CLANG_RESOURCE_DIR); - SmallString<128> P(Dir); - if (ClangResourceDir != "") - llvm::sys::path::append(P, ClangResourceDir); - else - llvm::sys::path::append(P, "..", Twine("lib") + CLANG_LIBDIR_SUFFIX, - "clang", CLANG_VERSION_STRING); - - return P.str(); + return Driver::GetResourcesPath(ClangExecutable, CLANG_RESOURCE_DIR); } static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args, |