11#include "llvm/Support/Path.h"
12#include "llvm/Support/Program.h"
19class LocationAdderDatabase :
public CompilationDatabase {
21 LocationAdderDatabase(std::unique_ptr<CompilationDatabase>
Base)
23 assert(this->Base !=
nullptr);
26 std::vector<std::string> getAllFiles()
const override {
27 return Base->getAllFiles();
30 std::vector<CompileCommand> getAllCompileCommands()
const override {
31 return addLocation(
Base->getAllCompileCommands());
34 std::vector<CompileCommand>
35 getCompileCommands(StringRef FilePath)
const override {
36 return addLocation(
Base->getCompileCommands(FilePath));
40 std::vector<CompileCommand>
41 addLocation(std::vector<CompileCommand> Cmds)
const {
42 for (
auto &
Cmd : Cmds) {
43 if (
Cmd.CommandLine.empty())
45 std::string &
Driver =
Cmd.CommandLine.front();
47 if (llvm::sys::path::is_absolute(Driver))
51 if (llvm::any_of(Driver,
52 [](
char C) {
return llvm::sys::path::is_separator(
C); }))
54 auto Absolute = llvm::sys::findProgramByName(Driver);
56 if (Absolute && llvm::sys::path::is_absolute(*Absolute))
57 Driver = std::move(*Absolute);
61 std::unique_ptr<CompilationDatabase>
Base;
65std::unique_ptr<CompilationDatabase>
67 return std::make_unique<LocationAdderDatabase>(std::move(
Base));
The JSON file list parser is used to communicate input to InstallAPI.
bool(*)(llvm::ArrayRef< const char * >, llvm::raw_ostream &, llvm::raw_ostream &, bool, bool) Driver