Fix compile_commands.json parsing when filename is absolute.

Some compile_commands.json generators will emit absolute paths for the
filename, such as cmake.
This commit is contained in:
Jacob Dufault 2017-10-31 15:43:27 -07:00
parent f48f818f4c
commit 1f0c1e922f

View File

@ -272,7 +272,11 @@ std::vector<Project::Entry> LoadCompilationEntriesFromDirectory(
clang_time.Pause(); // TODO: don't call clang::ToString in this block.
our_time.Resume();
std::string absolute_filename = directory + "/" + relative_filename;
std::string absolute_filename;
if (!relative_filename.empty() && relative_filename[0] == '/')
absolute_filename = relative_filename;
else
absolute_filename = directory + "/" + relative_filename;
entry.file = NormalizePathWithTestOptOut(absolute_filename);
entry.directory = directory;