summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clangd/GlobalCompilationDatabase.cpp')
-rw-r--r--clang-tools-extra/clangd/GlobalCompilationDatabase.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index 055f92c4734..e7cbc7bcc86 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -17,9 +17,19 @@ using namespace llvm;
namespace clang {
namespace clangd {
+static std::string getFallbackClangPath() {
+ static int Dummy;
+ std::string ClangdExecutable =
+ llvm::sys::fs::getMainExecutable("clangd", (void *)&Dummy);
+ SmallString<128> ClangPath;
+ ClangPath = llvm::sys::path::parent_path(ClangdExecutable);
+ llvm::sys::path::append(ClangPath, "clang");
+ return ClangPath.str();
+}
+
tooling::CompileCommand
GlobalCompilationDatabase::getFallbackCommand(PathRef File) const {
- std::vector<std::string> Argv = {"clang"};
+ std::vector<std::string> Argv = {getFallbackClangPath()};
// Clang treats .h files as C by default, resulting in unhelpful diagnostics.
// Parsing as Objective C++ is friendly to more cases.
if (sys::path::extension(File) == ".h")
OpenPOWER on IntegriCloud