From 560babbbfd4b4a9a964631e476deea7c880c32a9 Mon Sep 17 00:00:00 2001 From: sysRay Date: Thu, 21 Mar 2019 10:26:21 +0100 Subject: [PATCH] Allow absolute path for compilationDatabaseDirectory --- src/project.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/project.cc b/src/project.cc index 25bfa34c..ff347b33 100644 --- a/src/project.cc +++ b/src/project.cc @@ -46,6 +46,7 @@ limitations under the License. #include #include #include +#include using namespace clang; using namespace llvm; @@ -331,10 +332,12 @@ void Project::LoadDirectory(const std::string &root, Project::Folder &folder) { std::string err_msg; folder.entries.clear(); if (g_config->compilationDatabaseCommand.empty()) { - CDBDir = root; - if (g_config->compilationDatabaseDirectory.size()) - sys::path::append(CDBDir, g_config->compilationDatabaseDirectory); - sys::path::append(Path, CDBDir, "compile_commands.json"); + if (g_config->compilationDatabaseDirectory.size()) { + if (std::filesystem::path(g_config->compilationDatabaseDirectory).is_relative()) + sys::path::append(CDBDir, g_config->compilationDatabaseDirectory); + else + CDBDir = g_config->compilationDatabaseDirectory; + } } else { // If `compilationDatabaseCommand` is specified, execute it to get the // compdb.