From 3854e7864e6e647b8a7debba934fa2605820dfb9 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 12 Nov 2018 16:59:50 +0000 Subject: [PATCH] Revert "Make clang-based tools find libc++ on MacOS" This breaks the LLDB bots. llvm-svn: 346675 --- clang/include/clang/Lex/HeaderSearchOptions.h | 7 ------- clang/lib/Frontend/CreateInvocationFromCommandLine.cpp | 8 ++------ clang/lib/Frontend/InitHeaderSearch.cpp | 11 ++++++++--- clang/lib/Tooling/Tooling.cpp | 3 --- .../Inputs/mock-libcxx/include/c++/v1/mock_vector | 1 - clang/test/Tooling/clang-check-mac-libcxx-abspath.cpp | 17 ----------------- clang/test/Tooling/clang-check-mac-libcxx-relpath.cpp | 17 ----------------- 7 files changed, 10 insertions(+), 54 deletions(-) delete mode 100644 clang/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector delete mode 100644 clang/test/Tooling/clang-check-mac-libcxx-abspath.cpp delete mode 100644 clang/test/Tooling/clang-check-mac-libcxx-relpath.cpp diff --git a/clang/include/clang/Lex/HeaderSearchOptions.h b/clang/include/clang/Lex/HeaderSearchOptions.h index bdf7b43..e5b52b3 100644 --- a/clang/include/clang/Lex/HeaderSearchOptions.h +++ b/clang/include/clang/Lex/HeaderSearchOptions.h @@ -108,13 +108,6 @@ public: /// etc.). std::string ResourceDir; - /// Compiler install dir as detected by the Driver. - /// This is typically the directory that contains the clang executable, i.e. - /// the 'bin/' subdir of a clang distribution. - /// Only used to add include dirs for libc++ on Darwin. Please avoid relying - /// on this field for other purposes. - std::string InstallDir; - /// The directory used for the module cache. std::string ModuleCachePath; diff --git a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp index 3a5e1e8..2d4c40f 100644 --- a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp +++ b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp @@ -11,18 +11,17 @@ // //===----------------------------------------------------------------------===// +#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; @@ -103,8 +102,5 @@ std::unique_ptr 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 2f62ad3..deedb22 100644 --- a/clang/lib/Frontend/InitHeaderSearch.cpp +++ b/clang/lib/Frontend/InitHeaderSearch.cpp @@ -476,9 +476,14 @@ void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang, if (triple.isOSDarwin()) { // On Darwin, libc++ may be installed alongside the compiler in // include/c++/v1. - if (!HSOpts.InstallDir.empty()) { - // Get from foo/bin to foo. - SmallString<128> P(llvm::sys::path::parent_path(HSOpts.InstallDir)); + 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); + // Get foo/include/c++/v1 llvm::sys::path::append(P, "include", "c++", "v1"); AddUnmappedPath(P, CXXSystem, false); diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp index f113e47..cfdb32f 100644 --- a/clang/lib/Tooling/Tooling.cpp +++ b/clang/lib/Tooling/Tooling.cpp @@ -327,9 +327,6 @@ bool ToolInvocation::run() { Invocation->getPreprocessorOpts().addRemappedFile(It.getKey(), Input.release()); } - // Patch up the install dir, so we find the same standard library as the - // original compiler on MacOS. - Invocation->getHeaderSearchOpts().InstallDir = Driver->getInstalledDir(); return runInvocation(BinaryName, Compilation.get(), std::move(Invocation), std::move(PCHContainerOps)); } diff --git a/clang/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector b/clang/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector deleted file mode 100644 index 8512477..0000000 --- a/clang/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector +++ /dev/null @@ -1 +0,0 @@ -class vector {}; diff --git a/clang/test/Tooling/clang-check-mac-libcxx-abspath.cpp b/clang/test/Tooling/clang-check-mac-libcxx-abspath.cpp deleted file mode 100644 index 476ba3c..0000000 --- a/clang/test/Tooling/clang-check-mac-libcxx-abspath.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Clang on MacOS can find libc++ living beside the installed compiler. -// This test makes sure our libTooling-based tools emulate this properly. -// -// RUN: rm -rf %t -// RUN: mkdir %t -// -// Install the mock libc++ (simulates the libc++ directory structure). -// RUN: cp -r %S/Inputs/mock-libcxx %t/ -// -// Pretend clang is installed beside the mock library that we provided. -// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ -stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json -// RUN: cp "%s" "%t/test.cpp" -// clang-check will produce an error code if the mock library is not found. -// RUN: clang-check -p "%t" "%t/test.cpp" - -#include -vector v; diff --git a/clang/test/Tooling/clang-check-mac-libcxx-relpath.cpp b/clang/test/Tooling/clang-check-mac-libcxx-relpath.cpp deleted file mode 100644 index 099be5e..0000000 --- a/clang/test/Tooling/clang-check-mac-libcxx-relpath.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Clang on MacOS can find libc++ living beside the installed compiler. -// This test makes sure our libTooling-based tools emulate this properly. -// -// RUN: rm -rf %t -// RUN: mkdir %t -// -// Install the mock libc++ (simulates the libc++ directory structure). -// RUN: cp -r %S/Inputs/mock-libcxx %t/ -// -// Pretend clang is installed beside the mock library that we provided. -// RUN: echo '[{"directory":"%t","command":"mock-libcxx/bin/clang++ -stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json -// RUN: cp "%s" "%t/test.cpp" -// clang-check will produce an error code if the mock library is not found. -// RUN: clang-check -p "%t" "%t/test.cpp" - -#include -vector v; -- 2.7.4