diff --git a/src/compile_commands.cc b/src/compile_commands.cc index 01952f2..d9d572b 100644 --- a/src/compile_commands.cc +++ b/src/compile_commands.cc @@ -84,6 +84,9 @@ 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"; + auto extension = file_path.extension().string(); + bool is_header = CompileCommands::is_header(file_path) || extension.empty(); // Include std C++ headers that are without extensions + std::vector arguments; if(!build_path.empty()) { clangmm::CompilationDatabase db(build_path.string()); @@ -99,7 +102,8 @@ std::vector CompileCommands::get_arguments(const boost::filesystem: continue; } else if(cmd_arguments[c] == "-o" || cmd_arguments[c] == "-c" || - cmd_arguments[c] == "-x") { // Remove language arguments since some tools add languages not understood by clang + cmd_arguments[c] == "-x" || // Remove language arguments since some tools add languages not understood by clang + (is_header && cmd_arguments[c] == "-include-pch")) { // Header files should not use precompiled headers ignore_next = true; continue; } @@ -133,9 +137,6 @@ std::vector CompileCommands::get_arguments(const boost::filesystem: } arguments.emplace_back("-fretain-comments-from-system-headers"); - 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(is_header) { arguments.emplace_back("-Wno-pragma-once-outside-header"); arguments.emplace_back("-Wno-pragma-system-header-outside-header");