From 5fa89e2563f9f56c334c2b3c4c3b6fb1d58e09b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezgi=20=C3=87i=C3=A7ek?= Date: Mon, 19 Nov 2018 05:48:43 -0800 Subject: [PATCH] [purity] Disable clang Reviewed By: jvillard Differential Revision: D13118428 fbshipit-source-id: f4e86f286 --- infer/src/checkers/registerCheckers.ml | 10 ++-------- .../tests/codetoanalyze/c/performance/issues.exp | 4 ++++ infer/tests/codetoanalyze/c/performance/purity.c | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 infer/tests/codetoanalyze/c/performance/purity.c diff --git a/infer/src/checkers/registerCheckers.ml b/infer/src/checkers/registerCheckers.ml index 46ea88ddd..93a349023 100644 --- a/infer/src/checkers/registerCheckers.ml +++ b/infer/src/checkers/registerCheckers.ml @@ -116,19 +116,13 @@ let all_checkers = ( if Config.hoisting_report_only_expensive then [(Procedure Cost.checker, Language.Clang); (Procedure Cost.checker, Language.Java)] else [] ) - @ - if Config.purity then - [(Procedure Purity.checker, Language.Clang); (Procedure Purity.checker, Language.Java)] - else [] ) } + @ if Config.purity then [(Procedure Purity.checker, Language.Java)] else [] ) } ; { name= "Starvation analysis" ; active= Config.starvation ; callbacks= [ (Procedure Starvation.analyze_procedure, Language.Java) ; (Cluster Starvation.reporting, Language.Java) ] } - ; { name= "purity" - ; active= Config.purity - ; callbacks= - [(Procedure Purity.checker, Language.Clang); (Procedure Purity.checker, Language.Java)] } + ; {name= "purity"; active= Config.purity; callbacks= [(Procedure Purity.checker, Language.Java)]} ; { name= "Class loading analysis" ; active= Config.class_loads ; callbacks= [(Procedure ClassLoads.analyze_procedure, Language.Java)] } ] diff --git a/infer/tests/codetoanalyze/c/performance/issues.exp b/infer/tests/codetoanalyze/c/performance/issues.exp index 0e1436209..b66f84bdd 100644 --- a/infer/tests/codetoanalyze/c/performance/issues.exp +++ b/infer/tests/codetoanalyze/c/performance/issues.exp @@ -160,6 +160,10 @@ codetoanalyze/c/performance/loops.c, larger_state_FN, 3, EXPENSIVE_EXECUTION_TIM codetoanalyze/c/performance/loops.c, larger_state_FN, 4, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 1006, degree = 0] codetoanalyze/c/performance/loops.c, larger_state_FN, 5, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 1006, degree = 0] codetoanalyze/c/performance/loops.c, larger_state_FN, 7, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 1006, degree = 0] +codetoanalyze/c/performance/purity.c, loop, 2, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 7006, degree = 0] +codetoanalyze/c/performance/purity.c, loop, 2, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 7006, degree = 0] +codetoanalyze/c/performance/purity.c, loop, 3, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 7006, degree = 0] +codetoanalyze/c/performance/purity.c, loop, 6, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 7008, degree = 0] codetoanalyze/c/performance/switch_continue.c, test_switch, 3, CONDITION_ALWAYS_TRUE, no_bucket, WARNING, [Here] codetoanalyze/c/performance/switch_continue.c, test_switch, 3, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 602, degree = 0] codetoanalyze/c/performance/switch_continue.c, test_switch, 4, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 602, degree = 0] diff --git a/infer/tests/codetoanalyze/c/performance/purity.c b/infer/tests/codetoanalyze/c/performance/purity.c new file mode 100644 index 000000000..b32725bb0 --- /dev/null +++ b/infer/tests/codetoanalyze/c/performance/purity.c @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2018-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +void (*fun_ptr)(int); +// just to sanity check that we don't fail on cost with purity analysis enabled +int loop(int k) { + int p = 0; + for (int i = 0; i < 1000; i++) { + p = 3; + (*fun_ptr)(10); + } + return p; +}