diff --git a/src/clang_translation_unit.cc b/src/clang_translation_unit.cc index 52639c98..88365f23 100644 --- a/src/clang_translation_unit.cc +++ b/src/clang_translation_unit.cc @@ -69,11 +69,7 @@ std::unique_ptr ClangTranslationUnit::Create( std::vector& unsaved_files, unsigned flags) { std::vector args; - for (const std::string& a : arguments) - args.push_back(a.c_str()); - - std::vector platform_args = GetPlatformClangArguments(); - for (const auto& arg : platform_args) + for (auto& arg : arguments) args.push_back(arg.c_str()); CXTranslationUnit cx_tu; diff --git a/src/platform.h b/src/platform.h index 3e0fae2f..cbefb30e 100644 --- a/src/platform.h +++ b/src/platform.h @@ -42,7 +42,7 @@ void CopyFileTo(const std::string& destination, const std::string& source); bool IsSymLink(const std::string& path); // Returns any clang arguments that are specific to the current platform. -std::vector GetPlatformClangArguments(); +std::vector GetPlatformClangArguments(); // Free any unused memory and return it to the system. void FreeUnusedMemory(); diff --git a/src/platform_posix.cc b/src/platform_posix.cc index 025ad074..12cb4a37 100644 --- a/src/platform_posix.cc +++ b/src/platform_posix.cc @@ -259,7 +259,7 @@ bool IsSymLink(const std::string& path) { return lstat(path.c_str(), &buf) == 0 && S_ISLNK(buf.st_mode); } -std::vector GetPlatformClangArguments() { +std::vector GetPlatformClangArguments() { return {}; } diff --git a/src/platform_win.cc b/src/platform_win.cc index 608cf96e..87667d8d 100644 --- a/src/platform_win.cc +++ b/src/platform_win.cc @@ -129,12 +129,13 @@ bool IsSymLink(const std::string& path) { return false; } -std::vector GetPlatformClangArguments() { +std::vector GetPlatformClangArguments() { // // Found by executing // // $ clang++ -E -x c++ - -v // + // https://clang.llvm.org/docs/MSVCCompatibility.html // clang-format off return { diff --git a/src/project.cc b/src/project.cc index 35d86aab..3bec6f1a 100644 --- a/src/project.cc +++ b/src/project.cc @@ -27,6 +27,8 @@ #include #include +extern bool gTestOutputMode; + struct CompileCommandsEntry { std::string directory; std::string file; @@ -193,6 +195,12 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry( if (!AnyStartsWith(args, "-working-directory")) result.args.emplace_back("-working-directory=" + entry.directory); + if (!gTestOutputMode) { + std::vector platform = GetPlatformClangArguments(); + for (auto arg: platform) + result.args.push_back(arg); + } + bool next_flag_is_path = false; bool add_next_flag_to_quote_dirs = false; bool add_next_flag_to_angle_dirs = false; diff --git a/src/serializer.cc b/src/serializer.cc index 07db20de..02f8fd3c 100644 --- a/src/serializer.cc +++ b/src/serializer.cc @@ -10,9 +10,7 @@ #include -namespace { bool gTestOutputMode = false; -} // namespace //// Elementary types