25std::unique_ptr<compilation_database>
29 std::string error_message;
30 auto res = clang::tooling::CompilationDatabase::autoDetectFromDirectory(
33 if (!error_message.empty())
36 return std::make_unique<compilation_database>(std::move(res), cfg);
40 std::unique_ptr<clang::tooling::CompilationDatabase> base,
42 : base_{
std::move(base)}
59 return base().getAllFiles();
62std::vector<clang::tooling::CompileCommand>
65 auto commands =
base().getCompileCommands(FilePath);
72std::vector<clang::tooling::CompileCommand>
75 auto commands =
base().getAllCompileCommands();
83 const std::string &filename)
const
92 const std::vector<std::string> &files)
const
96 auto commands =
base().getAllCompileCommands();
98 for (
const auto &command : commands) {
99 result += std::count_if(
100 files.begin(), files.end(), [&command](
const auto &file) {
101 return (command.Filename == file) ||
102 (std::filesystem::weakly_canonical(command.Filename)
111 std::vector<clang::tooling::CompileCommand> &commands)
const
114 if (
config().query_driver && !
config().query_driver().empty()) {
115 for (
auto &compile_command : commands) {
117 ? compile_command.CommandLine.at(0)
125 std::vector<std::string> system_header_args;
126 for (
const auto &path : extractor.system_include_paths()) {
127 system_header_args.emplace_back(
"-isystem");
128 system_header_args.emplace_back(path);
131 compile_command.CommandLine.insert(
132 compile_command.CommandLine.begin() + 1,
133 system_header_args.begin(), system_header_args.end());
135 if (!extractor.target().empty()) {
136 compile_command.CommandLine.insert(
137 compile_command.CommandLine.begin() + 1,
138 fmt::format(
"--target={}", extractor.target()));
145 for (
auto &compile_command : commands) {
146 compile_command.CommandLine.insert(
148 compile_command.CommandLine.begin() + 1,
156 for (
auto &compile_command : commands) {
159 [&flag](
const auto &arg) { return flag == arg; });