From 676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 19 Jan 2019 10:04:05 +0000 Subject: Vendor import of clang trunk r351319 (just before the release_80 branch point): https://llvm.org/svn/llvm-project/cfe/trunk@351319 --- lib/Tooling/JSONCompilationDatabase.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/Tooling/JSONCompilationDatabase.cpp') diff --git a/lib/Tooling/JSONCompilationDatabase.cpp b/lib/Tooling/JSONCompilationDatabase.cpp index 2fa5fce279d60..b0feaa229c11c 100644 --- a/lib/Tooling/JSONCompilationDatabase.cpp +++ b/lib/Tooling/JSONCompilationDatabase.cpp @@ -157,13 +157,16 @@ std::vector unescapeCommandLine(JSONCommandLineSyntax Syntax, return parser.parse(); } +// This plugin locates a nearby compile_command.json file, and also infers +// compile commands for files not present in the database. class JSONCompilationDatabasePlugin : public CompilationDatabasePlugin { std::unique_ptr loadFromDirectory(StringRef Directory, std::string &ErrorMessage) override { SmallString<1024> JSONDatabasePath(Directory); llvm::sys::path::append(JSONDatabasePath, "compile_commands.json"); - return JSONCompilationDatabase::loadFromFile( + auto Base = JSONCompilationDatabase::loadFromFile( JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect); + return Base ? inferMissingCompileCommands(std::move(Base)) : nullptr; } }; -- cgit v1.2.3