From 8c481d2d9f2be113d819afd138c70d87feb00583 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Thu, 3 Nov 2016 08:04:05 -0700 Subject: [PATCH] [clang] pass -fno-cxx-modules to clang -### instead of the clang -cc1 commands Summary: -fno-cxx-modules is only supported by the clang driver. Reviewed By: akotulski Differential Revision: D4124273 fbshipit-source-id: cc3de93 --- infer/src/clang/ClangCommand.re | 1 - infer/src/clang/ClangWrapper.re | 13 ++++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/infer/src/clang/ClangCommand.re b/infer/src/clang/ClangCommand.re index c00ce5143..503567396 100644 --- a/infer/src/clang/ClangCommand.re +++ b/infer/src/clang/ClangCommand.re @@ -100,7 +100,6 @@ let clang_cc1_cmd_sanitizer cmd => { }; let post_args_rev = [] |> IList.rev_append ["-include", Config.lib_dir /\/ "clang_wrappers" /\/ "global_defines.h"] |> - argv_do_if (has_flag cmd "-fmodules") (argv_cons "-fno-cxx-modules") |> /* Never error on warnings. Clang is often more strict than Apple's version. These arguments are appended at the end to override previous opposite settings. How it's done: suppress all the warnings, since there are no warnings, compiler can't elevate them to error diff --git a/infer/src/clang/ClangWrapper.re b/infer/src/clang/ClangWrapper.re index 652ca2859..5b0cabe69 100644 --- a/infer/src/clang/ClangWrapper.re +++ b/infer/src/clang/ClangWrapper.re @@ -22,7 +22,18 @@ type action_item = let normalize (args: array string) :list action_item => { let cmd = ClangCommand.mk ClangQuotes.SingleQuotes args; let clang_hashhashhash = - Printf.sprintf "%s 2>&1" (ClangCommand.prepend_arg "-###" cmd |> ClangCommand.command_to_run); + Printf.sprintf + "%s 2>&1" + ( + ClangCommand.prepend_arg "-###" cmd |> + /* c++ modules are not supported, so let clang know in case it was passed + "-fmodules". Unfortunately we cannot know accurately if "-fmodules" was passed because we + don't go into argument files at this point ("clang -### ..." will do that for us), so we + also pass "-Qunused-arguments" to silence the potential warning that "-fno-cxx-modules" + was ignored. Moreover, "-fno-cxx-modules" is only accepted by the clang driver so we have + to pass it now. */ + ClangCommand.append_args ["-fno-cxx-modules", "-Qunused-arguments"] |> ClangCommand.command_to_run + ); Logging.out "clang -### invocation: %s@\n" clang_hashhashhash; let normalized_commands = ref []; let one_line line =>