summaryrefslogtreecommitdiffstats
path: root/clangd/GlobalCompilationDatabase.cpp
diff options
context:
space:
mode:
authorAdam Nemet <anemet@apple.com>2017-05-15 18:14:35 +0000
committerAdam Nemet <anemet@apple.com>2017-05-15 18:14:35 +0000
commita196a6f1b9a5ea2a48ff7f20b86f467b07766bc3 (patch)
tree406fcb7750dad212d5e7b16e4d1c00280750d595 /clangd/GlobalCompilationDatabase.cpp
parentf2be6674f565211f62317f727b18501867df6eb8 (diff)
Revert "[ClangD] Refactor clangd into separate components"
This reverts commit r303067. Caused http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/34305/ And even after Simon's fix there is still a test failure. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@303094 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clangd/GlobalCompilationDatabase.cpp')
-rw-r--r--clangd/GlobalCompilationDatabase.cpp65
1 files changed, 0 insertions, 65 deletions
diff --git a/clangd/GlobalCompilationDatabase.cpp b/clangd/GlobalCompilationDatabase.cpp
deleted file mode 100644
index 91d77026..00000000
--- a/clangd/GlobalCompilationDatabase.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-//===--- GlobalCompilationDatabase.cpp --------------------------*- C++-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===---------------------------------------------------------------------===//
-
-#include "GlobalCompilationDatabase.h"
-#include "clang/Tooling/CompilationDatabase.h"
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/Path.h"
-
-using namespace clang::clangd;
-using namespace clang;
-
-std::vector<tooling::CompileCommand>
-DirectoryBasedGlobalCompilationDatabase::getCompileCommands(PathRef File) {
- std::vector<tooling::CompileCommand> Commands;
-
- auto CDB = getCompilationDatabase(File);
- if (!CDB)
- return {};
- return CDB->getCompileCommands(File);
-}
-
-tooling::CompilationDatabase *
-DirectoryBasedGlobalCompilationDatabase::getCompilationDatabase(PathRef File) {
- std::lock_guard<std::mutex> Lock(Mutex);
-
- namespace path = llvm::sys::path;
-
- assert((path::is_absolute(File, path::Style::posix) ||
- path::is_absolute(File, path::Style::windows)) &&
- "path must be absolute");
-
- for (auto Path = path::parent_path(File); !Path.empty();
- Path = path::parent_path(Path)) {
-
- auto CachedIt = CompilationDatabases.find(Path);
- if (CachedIt != CompilationDatabases.end())
- return CachedIt->second.get();
- std::string Error;
- auto CDB = tooling::CompilationDatabase::loadFromDirectory(Path, Error);
- if (!CDB) {
- if (!Error.empty()) {
- // FIXME(ibiryukov): logging
- // Output.log("Error when trying to load compilation database from " +
- // Twine(Path) + ": " + Twine(Error) + "\n");
- }
- continue;
- }
-
- // FIXME(ibiryukov): Invalidate cached compilation databases on changes
- auto result = CDB.get();
- CompilationDatabases.insert(std::make_pair(Path, std::move(CDB)));
- return result;
- }
-
- // FIXME(ibiryukov): logging
- // Output.log("Failed to find compilation database for " + Twine(File) +
- // "\n");
- return nullptr;
-}