data: Fixed no indexer commands created for relative file paths in cdb (issue #388)

bug id = 388
This commit is contained in:
Eberhard Graether
2017-05-23 11:42:39 +02:00
parent 9b73d73a85
commit 13f7acbb70
2 changed files with 15 additions and 5 deletions
@@ -21,10 +21,14 @@ std::vector<FilePath> IndexerCommandCxxCdb::getSourceFilesFromCDB(const FilePath
std::vector<FilePath> filePaths;
if (cdb)
{
std::vector<std::string> 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;
+8 -2
View File
@@ -145,13 +145,19 @@ std::vector<std::shared_ptr<IndexerCommand>> 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<std::string> currentCompilerFlags = compilerFlags;
currentCompilerFlags.insert(currentCompilerFlags.end(), command.CommandLine.begin(), command.CommandLine.end());
indexerCommands.push_back(std::make_shared<IndexerCommandCxxCdb>(
FilePath(command.Filename),
FilePath(path),
indexedPaths,
excludedPaths,
FilePath(command.Directory),