|
|
|
|
@ -82,12 +82,33 @@ CompileCommands::CompileCommands(const boost::filesystem::path &build_path) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::vector<std::string> CompileCommands::get_arguments(const boost::filesystem::path &build_path, const boost::filesystem::path &file_path) { |
|
|
|
|
std::vector<std::string> CompileCommands::get_arguments(const boost::filesystem::path &build_path, const boost::filesystem::path &file_path_) { |
|
|
|
|
auto file_path = file_path_; |
|
|
|
|
|
|
|
|
|
std::string default_std_argument = "-std=c++1y"; |
|
|
|
|
|
|
|
|
|
auto extension = file_path.extension().string(); |
|
|
|
|
bool is_header = CompileCommands::is_header(file_path) || extension.empty(); // Include std C++ headers that are without extensions
|
|
|
|
|
|
|
|
|
|
// If header file, use a source file in the same folder if one exists
|
|
|
|
|
if(is_header && !extension.empty()) { |
|
|
|
|
auto parent_path = file_path.parent_path(); |
|
|
|
|
auto stem = file_path.stem(); |
|
|
|
|
CompileCommands compile_commands(build_path); |
|
|
|
|
bool found = false; |
|
|
|
|
for(auto &command : compile_commands.commands) { |
|
|
|
|
// Priority on source file with the same filename (extension excluded) as the header file
|
|
|
|
|
if(command.file.stem() == stem) { |
|
|
|
|
file_path = command.file; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if(!found && command.file.parent_path() == parent_path) { |
|
|
|
|
file_path = command.file; |
|
|
|
|
found = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::vector<std::string> arguments; |
|
|
|
|
if(!build_path.empty()) { |
|
|
|
|
clangmm::CompilationDatabase db(build_path.string()); |
|
|
|
|
|