41 lines · cpp
1// RUN: %clang_analyze_cc1 %s \2// RUN: -analyzer-checker=core \3// RUN: -analyzer-checker=debug.ExprInspection \4// RUN: 2>&1 | FileCheck %s5 6// In this test we check whether the solver's symbol simplification mechanism7// is capable of reaching a fixpoint. This should be done after one iteration.8 9void clang_analyzer_printState();10 11void test(int a, int b, int c) {12 if (a + b != c)13 return;14 clang_analyzer_printState();15 // CHECK: "constraints": [16 // CHECK-NEXT: { "symbol": "((reg_$0<int a>) + (reg_$2<int b>)) != (reg_$5<int c>)", "range": "{ [0, 0] }" }17 // CHECK-NEXT: ],18 // CHECK-NEXT: "equivalence_classes": [19 // CHECK-NEXT: [ "(reg_$0<int a>) + (reg_$2<int b>)", "reg_$5<int c>" ]20 // CHECK-NEXT: ],21 // CHECK-NEXT: "disequality_info": null,22 23 // Simplification starts here.24 if (b != 0)25 return;26 clang_analyzer_printState();27 // CHECK: "constraints": [28 // CHECK-NEXT: { "symbol": "(reg_$0<int a>) != (reg_$5<int c>)", "range": "{ [0, 0] }" },29 // CHECK-NEXT: { "symbol": "reg_$2<int b>", "range": "{ [0, 0] }" }30 // CHECK-NEXT: ],31 // CHECK-NEXT: "equivalence_classes": [32 // CHECK-NEXT: [ "(reg_$0<int a>) != (reg_$5<int c>)" ],33 // CHECK-NEXT: [ "reg_$0<int a>", "reg_$5<int c>" ]34 // CHECK-NEXT: ],35 // CHECK-NEXT: "disequality_info": null,36 37 // Keep the symbols and the constraints! alive.38 (void)(a * b * c);39 return;40}41