From 13f7acbb70a5899d238c4387e17efb33ee0f0e48 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Tue, 23 May 2017 11:42:39 +0200 Subject: [PATCH] data: Fixed no indexer commands created for relative file paths in cdb (issue #388) bug id = 388 --- src/lib_cxx/data/indexer/IndexerCommandCxxCdb.cpp | 10 +++++++--- src/lib_cxx/project/SourceGroupCxx.cpp | 10 ++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/lib_cxx/data/indexer/IndexerCommandCxxCdb.cpp b/src/lib_cxx/data/indexer/IndexerCommandCxxCdb.cpp index 10a8e0e4..e04ded9a 100644 --- a/src/lib_cxx/data/indexer/IndexerCommandCxxCdb.cpp +++ b/src/lib_cxx/data/indexer/IndexerCommandCxxCdb.cpp @@ -21,10 +21,14 @@ std::vector IndexerCommandCxxCdb::getSourceFilesFromCDB(const FilePath std::vector filePaths; if (cdb) { - std::vector files = cdb->getAllFiles(); - for (const std::string& file : files) + for (const clang::tooling::CompileCommand& command : cdb->getAllCompileCommands()) { - filePaths.push_back(FilePath(file)); + FilePath path = FilePath(command.Filename).canonical(); + if (!path.isAbsolute()) + { + path = FilePath(command.Directory + '/' + command.Filename).canonical(); + } + filePaths.push_back(path); } } return filePaths; diff --git a/src/lib_cxx/project/SourceGroupCxx.cpp b/src/lib_cxx/project/SourceGroupCxx.cpp index 6122f073..08aa65d2 100644 --- a/src/lib_cxx/project/SourceGroupCxx.cpp +++ b/src/lib_cxx/project/SourceGroupCxx.cpp @@ -145,13 +145,19 @@ std::vector> SourceGroupCxx::getIndexerCommands( for (clang::tooling::CompileCommand command: cdb->getAllCompileCommands()) { - if (sourceFilePathsToIndex.find(FilePath(command.Filename)) != sourceFilePathsToIndex.end()) + FilePath path = FilePath(command.Filename).canonical(); + if (!path.isAbsolute()) + { + path = FilePath(command.Directory + '/' + command.Filename).canonical(); + } + + if (sourceFilePathsToIndex.find(path) != sourceFilePathsToIndex.end()) { std::vector currentCompilerFlags = compilerFlags; currentCompilerFlags.insert(currentCompilerFlags.end(), command.CommandLine.begin(), command.CommandLine.end()); indexerCommands.push_back(std::make_shared( - FilePath(command.Filename), + FilePath(path), indexedPaths, excludedPaths, FilePath(command.Directory),