Browse Source

Cleanup of CompileCommands::get_arguments and disables more outside header warnings for header files

merge-requests/365/head
eidheim 8 years ago
parent
commit
1575eb0072
  1. 16
      src/compile_commands.cc

16
src/compile_commands.cc

@ -81,10 +81,11 @@ 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) {
std::vector<std::string> arguments;
if(!build_path.empty()) {
clangmm::CompilationDatabase db(build_path.string()); clangmm::CompilationDatabase db(build_path.string());
clangmm::CompileCommands commands(file_path.string(), db); clangmm::CompileCommands commands(file_path.string(), db);
std::vector<clangmm::CompileCommand> cmds = commands.get_commands(); auto cmds = commands.get_commands();
std::vector<std::string> arguments;
for (auto &cmd : cmds) { for (auto &cmd : cmds) {
auto cmd_arguments = cmd.get_arguments(); auto cmd_arguments = cmd.get_arguments();
bool ignore_next=false; bool ignore_next=false;
@ -100,6 +101,7 @@ std::vector<std::string> CompileCommands::get_arguments(const boost::filesystem:
arguments.emplace_back(cmd_arguments[c]); arguments.emplace_back(cmd_arguments[c]);
} }
} }
}
auto clang_version_string=clangmm::to_string(clang_getClangVersion()); auto clang_version_string=clangmm::to_string(clang_getClangVersion());
const static std::regex clang_version_regex("^[A-Za-z ]+([0-9.]+).*$"); const static std::regex clang_version_regex("^[A-Za-z ]+([0-9.]+).*$");
std::smatch sm; std::smatch sm;
@ -125,13 +127,11 @@ std::vector<std::string> CompileCommands::get_arguments(const boost::filesystem:
extension!=".c") extension!=".c")
arguments.emplace_back("-xc++"); arguments.emplace_back("-xc++");
if(extension.empty()) { // For std headers if(extension.empty() || (1<extension.size() && extension[1]=='h') || extension==".tcc") {
arguments.emplace_back("-xc++");
arguments.emplace_back("-w"); // Disable all warnings
}
if((extension.size()>1 && extension[1]=='h') || extension==".tcc")
arguments.emplace_back("-Wno-pragma-once-outside-header"); arguments.emplace_back("-Wno-pragma-once-outside-header");
arguments.emplace_back("-Wno-pragma-system-header-outside-header");
arguments.emplace_back("-Wno-include-next-outside-header");
}
if(!build_path.empty()) { if(!build_path.empty()) {
arguments.emplace_back("-working-directory"); arguments.emplace_back("-working-directory");

Loading…
Cancel
Save