From b9b31c3c93b9bbf7048e53d23d4525e6aba69e06 Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 4 Oct 2018 09:20:59 +0200 Subject: [PATCH] No longer adds -fretain-comments-from-system-headers when using pch file. Related to #394 --- src/compile_commands.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/compile_commands.cc b/src/compile_commands.cc index fa751b5..aadd89d 100644 --- a/src/compile_commands.cc +++ b/src/compile_commands.cc @@ -1,5 +1,6 @@ #include "compile_commands.h" #include "clangmm.h" +#include #include #include @@ -136,7 +137,10 @@ std::vector CompileCommands::get_arguments(const boost::filesystem: arguments.emplace_back("-I" + (boost::filesystem::path(env_msystem_prefix) / "lib/clang" / clang_version / "include").string()); #endif } - arguments.emplace_back("-fretain-comments-from-system-headers"); + + // Do not add -fretain-comments-from-system-headers if pch is used, since the pch was most likely made without this flag + if(std::none_of(arguments.begin(), arguments.end(), [](const std::string &argument) { return argument == "-include-pch"; })) + arguments.emplace_back("-fretain-comments-from-system-headers"); if(is_header) { arguments.emplace_back("-Wno-pragma-once-outside-header");