diff --git a/libclangmm b/libclangmm index 5f60c3a..6846577 160000 --- a/libclangmm +++ b/libclangmm @@ -1 +1 @@ -Subproject commit 5f60c3a456154ad4c5ef25103f3865668d1f64eb +Subproject commit 684657732bff4fb8b5f4e7099111d633060ab774 diff --git a/src/compile_commands.cc b/src/compile_commands.cc index 18ac059..89a40df 100644 --- a/src/compile_commands.cc +++ b/src/compile_commands.cc @@ -81,27 +81,36 @@ 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) { + std::string default_std_argument="-std=c++1y"; + std::vector arguments; 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; + if(db) { + 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]); } } + else + arguments.emplace_back(default_std_argument); } + else + arguments.emplace_back(default_std_argument); + auto clang_version_string=clangmm::to_string(clang_getClangVersion()); const static std::regex clang_version_regex("^[A-Za-z ]+([0-9.]+).*$"); std::smatch sm;