From 01b57b4f383ab7cbe52be9da6269f21ee0de4800 Mon Sep 17 00:00:00 2001 From: Andrzej Kotulski Date: Tue, 13 Dec 2016 06:30:25 -0800 Subject: [PATCH] [clang] Always compile with -O0 flag Summary: This is to prevent clang from changing AST to make it more performant and less readable. Reported in https://github.com/facebook/infer/issues/522 + unrelated `refmt` fix Reviewed By: jvillard Differential Revision: D4319731 fbshipit-source-id: 176dfcf --- infer/src/clang/ClangCommand.re | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/infer/src/clang/ClangCommand.re b/infer/src/clang/ClangCommand.re index 0de6fa823..daad3b37d 100644 --- a/infer/src/clang/ClangCommand.re +++ b/infer/src/clang/ClangCommand.re @@ -16,7 +16,8 @@ type t = { }; let fcp_dir = - Config.bin_dir ^\/ Filename.parent_dir_name ^\/ Filename.parent_dir_name ^\/ "facebook-clang-plugins"; + Config.bin_dir ^\/ + Filename.parent_dir_name ^\/ Filename.parent_dir_name ^\/ "facebook-clang-plugins"; /** path of the plugin to load in clang */ @@ -174,7 +175,9 @@ let with_plugin_args args => { "-plugin-arg-" ^ plugin_name, "PREPEND_CURRENT_DIR=1" ]; - let args_after_rev = [] |> argv_do_if Config.fcp_syntax_only (argv_cons "-fsyntax-only"); + /* add -O0 option to avoid compiler obfuscation of AST */ + let args_after_rev = + [] |> argv_cons "-O0" |> argv_do_if Config.fcp_syntax_only (argv_cons "-fsyntax-only"); {...args, argv: IList.rev_append args_before_rev (args.argv @ IList.rev args_after_rev)} };