summaryrefslogtreecommitdiffstats
path: root/clangd/GlobalCompilationDatabase.cpp
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2017-09-20 07:24:15 +0000
committerIlya Biryukov <ibiryukov@google.com>2017-09-20 07:24:15 +0000
commit164160e36f66c1c339432b580e2731127130ca2b (patch)
treeb3e8c9c9082767601596fe3db9ca2826071ecb97 /clangd/GlobalCompilationDatabase.cpp
parent69157d1b22db178ff418fc3b073017979f5f4289 (diff)
[clangd] Introduced Logger interface.
Summary: This fixes a bunch of logging-related FIXMEs. Reviewers: bkramer, krasimir, malaperle Reviewed By: malaperle Subscribers: malaperle, klimek, cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D37972 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@313730 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clangd/GlobalCompilationDatabase.cpp')
-rw-r--r--clangd/GlobalCompilationDatabase.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/clangd/GlobalCompilationDatabase.cpp b/clangd/GlobalCompilationDatabase.cpp
index 9cf8572c..cfb9cc94 100644
--- a/clangd/GlobalCompilationDatabase.cpp
+++ b/clangd/GlobalCompilationDatabase.cpp
@@ -11,6 +11,7 @@
#include "clang/Tooling/CompilationDatabase.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
+#include "Logger.h"
namespace clang {
namespace clangd {
@@ -36,6 +37,10 @@ tooling::CompileCommand getDefaultCompileCommand(PathRef File) {
/*Output=*/"");
}
+DirectoryBasedGlobalCompilationDatabase::
+ DirectoryBasedGlobalCompilationDatabase(clangd::Logger &Logger)
+ : Logger(Logger) {}
+
std::vector<tooling::CompileCommand>
DirectoryBasedGlobalCompilationDatabase::getCompileCommands(PathRef File) {
std::vector<tooling::CompileCommand> Commands;
@@ -77,26 +82,19 @@ DirectoryBasedGlobalCompilationDatabase::getCompilationDatabase(PathRef File) {
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");
- }
+ if (!CDB)
continue;
- }
// FIXME(ibiryukov): Invalidate cached compilation databases on changes
- auto result = CDB.get();
+ auto Result = CDB.get();
CompilationDatabases.insert(std::make_pair(Path, std::move(CDB)));
- return result;
+ return Result;
}
- // FIXME(ibiryukov): logging
- // Output.log("Failed to find compilation database for " + Twine(File) +
- // "\n");
+ Logger.log("Failed to find compilation database for " + Twine(File) + "\n");
return nullptr;
}