[cost] Ignore character symbols in the cost results

Summary:
This diff ignores character symbols in the cost results, in order to
avoid FPs from parser code.

Reviewed By: ezgicicek

Differential Revision: D17132053

fbshipit-source-id: d9cf8bd26
master
Sungkeun Cho 5 years ago committed by Facebook Github Bot
parent 63a5ffb4dc
commit f79871c5fa

@ -450,7 +450,9 @@ module Val = struct
(if may_last_field then ", may_last_field" else "")
(if is_java then ", is_java" else "") ;
match typ.Typ.desc with
| Tint IBool | Tfloat _ | Tfun _ | TVar _ ->
| Tint (IBool | IChar | ISChar | IUChar) ->
itv_val ~non_int:(Language.curr_language_is Java)
| Tfloat _ | Tfun _ | TVar _ ->
itv_val ~non_int:true
| Tint _ | Tvoid ->
itv_val ~non_int:false

@ -4,6 +4,8 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <stdint.h>
// Cost: 5
int foo_OK() {
int i, j;
@ -147,3 +149,12 @@ void infinite() {
}
void call_infinite() { infinite(); }
// Cost should not include the symbol of c.
void ignore_character_symbols_constant_FP(char c) {
for (; c < 'z';) {
if (rand()) {
c = 'a';
}
}
}

@ -19,16 +19,17 @@ codetoanalyze/c/performance/compound_loop_guard.c, while_and_or, 0, INFINITE_EXE
codetoanalyze/c/performance/compound_loop_guard.c, while_and_or, 2, CONDITION_ALWAYS_TRUE, no_bucket, WARNING, [Here]
codetoanalyze/c/performance/compound_loop_guard.c, while_and_or, 3, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [<LHS trace>,Assignment,Binary operation: ([0, +oo] + 1):signed32]
codetoanalyze/c/performance/cost_test.c, alias_OK, 5, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [Binary operation: ([-oo, +oo] + 1):signed32]
codetoanalyze/c/performance/cost_test.c, call_infinite, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Call to infinite,Unbounded loop,Loop at line 144, column 3]
codetoanalyze/c/performance/cost_test.c, call_infinite, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Call to infinite,Unbounded loop,Loop at line 146, column 3]
codetoanalyze/c/performance/cost_test.c, call_while_upto20_minus100_bad, 0, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 606, O(1), degree = 0]
codetoanalyze/c/performance/cost_test.c, infinite, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop at line 144, column 3]
codetoanalyze/c/performance/cost_test.c, ignore_character_symbols_constant_FP, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop at line 155, column 3]
codetoanalyze/c/performance/cost_test.c, infinite, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop at line 146, column 3]
codetoanalyze/c/performance/cost_test.c, infinite, 3, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [<LHS trace>,Assignment,<RHS trace>,Assignment,Binary operation: ([-oo, +oo] + [0, +oo]):signed32]
codetoanalyze/c/performance/cost_test.c, infinite_FN, 3, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [<LHS trace>,Assignment,<RHS trace>,Assignment,Binary operation: ([-oo, +oo] + [0, +oo]):signed32]
codetoanalyze/c/performance/cost_test.c, loop0_bad, 2, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 1103, O(1), degree = 0]
codetoanalyze/c/performance/cost_test.c, loop1_bad, 3, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 1205, O(1), degree = 0]
codetoanalyze/c/performance/cost_test.c, loop2_bad, 2, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 2 + 10 ⋅ k + 2 ⋅ (1+max(0, k)), O(k), degree = 1,{1+max(0, k)},Loop at line 85, column 3,{k},Loop at line 85, column 3]
codetoanalyze/c/performance/cost_test.c, loop2_bad, 2, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 2 + 10 ⋅ k + 2 ⋅ (1+max(0, k)), O(k), degree = 1,{1+max(0, k)},Loop at line 87, column 3,{k},Loop at line 87, column 3]
codetoanalyze/c/performance/cost_test.c, main_bad, 8, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 206, O(1), degree = 0]
codetoanalyze/c/performance/cost_test.c, while_upto20_bad, 1, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 1 + 4 ⋅ (-m + 20) + (21-min(20, m)), O((-m + 21)), degree = 1,{21-min(20, m)},Loop at line 117, column 3,{-m + 20},Loop at line 117, column 3]
codetoanalyze/c/performance/cost_test.c, while_upto20_bad, 1, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 1 + 4 ⋅ (-m + 20) + (21-min(20, m)), O((-m + 21)), degree = 1,{21-min(20, m)},Loop at line 119, column 3,{-m + 20},Loop at line 119, column 3]
codetoanalyze/c/performance/cost_test_deps.c, if_bad_loop, 2, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 201, O(1), degree = 0]
codetoanalyze/c/performance/cost_test_deps.c, if_bad_loop, 4, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [<LHS trace>,Assignment,Binary operation: ([0, +oo] + 1):signed32]
codetoanalyze/c/performance/cost_test_deps.c, loop_despite_inferbo, 3, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 1205, O(1), degree = 0]

@ -170,4 +170,13 @@ public class Cost_test {
}
}
}
// Cost should not include the symbol of c.
void ignore_character_symbols_constant(char c) {
for (; c < 'z'; ) {
if (rand()) {
c = 'a';
}
}
}
}

Loading…
Cancel
Save