From 1575eb0072dd605aa2c220108b8b11462ba05494 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sun, 20 Aug 2017 08:32:09 +0200 Subject: [PATCH] Cleanup of CompileCommands::get_arguments and disables more outside header warnings for header files --- src/compile_commands.cc | 42 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/compile_commands.cc b/src/compile_commands.cc index 0c3731a..2c0d7aa 100644 --- a/src/compile_commands.cc +++ b/src/compile_commands.cc @@ -81,23 +81,25 @@ CompileCommands::CompileCommands(const boost::filesystem::path &build_path) { } std::vector CompileCommands::get_arguments(const boost::filesystem::path &build_path, const boost::filesystem::path &file_path) { - clangmm::CompilationDatabase db(build_path.string()); - clangmm::CompileCommands commands(file_path.string(), db); - std::vector cmds = commands.get_commands(); std::vector arguments; - for (auto &cmd : cmds) { - auto cmd_arguments = cmd.get_arguments(); - bool ignore_next=false; - for (size_t c = 1; c < cmd_arguments.size(); c++) { - if(ignore_next) { - ignore_next=false; - continue; - } - else if(cmd_arguments[c]=="-o" || cmd_arguments[c]=="-c") { - ignore_next=true; - continue; + if(!build_path.empty()) { + clangmm::CompilationDatabase db(build_path.string()); + clangmm::CompileCommands commands(file_path.string(), db); + auto cmds = commands.get_commands(); + for (auto &cmd : cmds) { + auto cmd_arguments = cmd.get_arguments(); + bool ignore_next=false; + for (size_t c = 1; c < cmd_arguments.size(); c++) { + if(ignore_next) { + ignore_next=false; + continue; + } + else if(cmd_arguments[c]=="-o" || cmd_arguments[c]=="-c") { + ignore_next=true; + continue; + } + arguments.emplace_back(cmd_arguments[c]); } - arguments.emplace_back(cmd_arguments[c]); } } auto clang_version_string=clangmm::to_string(clang_getClangVersion()); @@ -125,13 +127,11 @@ std::vector CompileCommands::get_arguments(const boost::filesystem: extension!=".c") arguments.emplace_back("-xc++"); - if(extension.empty()) { // For std headers - arguments.emplace_back("-xc++"); - arguments.emplace_back("-w"); // Disable all warnings - } - - if((extension.size()>1 && extension[1]=='h') || extension==".tcc") + if(extension.empty() || (1