Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Analyzer][solver] Add dump methods for (dis)equality classes.
This proved to be very useful during debugging. Differential Revision: https://reviews.llvm.org/D103967
- Loading branch information
Gabor Marton
committed
Jun 28, 2021
1 parent
ad81dea
commit 6f3b775
Showing
4 changed files
with
195 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
clang/test/Analysis/expr-inspection-printState-diseq-info.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// RUN: %clang_analyze_cc1 \ | ||
// RUN: -analyzer-checker=debug.ExprInspection %s 2>&1 | FileCheck %s | ||
|
||
void clang_analyzer_printState(); | ||
|
||
void test_disequality_info(int e0, int b0, int b1, int c0) { | ||
int e1 = e0 - b0; | ||
if (b0 == 2) { | ||
int e2 = e1 - b1; | ||
if (e2 > 0) { | ||
if (b1 != c0) | ||
clang_analyzer_printState(); | ||
} | ||
} | ||
} | ||
|
||
// CHECK: "disequality_info": [ | ||
// CHECK-NEXT: { | ||
// CHECK-NEXT: "class": [ "reg_$2<int b1>" ], | ||
// CHECK-NEXT: "disequal_to": [ | ||
// CHECK-NEXT: [ "(reg_$0<int e0>) - 2" ], | ||
// CHECK-NEXT: [ "reg_$3<int c0>" ]] | ||
// CHECK-NEXT: }, | ||
// CHECK-NEXT: { | ||
// CHECK-NEXT: "class": [ "(reg_$0<int e0>) - 2" ], | ||
// CHECK-NEXT: "disequal_to": [ | ||
// CHECK-NEXT: [ "reg_$2<int b1>" ]] | ||
// CHECK-NEXT: }, | ||
// CHECK-NEXT: { | ||
// CHECK-NEXT: "class": [ "reg_$3<int c0>" ], | ||
// CHECK-NEXT: "disequal_to": [ | ||
// CHECK-NEXT: [ "reg_$2<int b1>" ]] | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: ], |
21 changes: 21 additions & 0 deletions
21
clang/test/Analysis/expr-inspection-printState-eq-classes.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// RUN: %clang_analyze_cc1 \ | ||
// RUN: -analyzer-checker=debug.ExprInspection %s 2>&1 | FileCheck %s | ||
|
||
void clang_analyzer_printState(); | ||
|
||
void test_equivalence_classes(int a, int b, int c, int d) { | ||
if (a + b != c) | ||
return; | ||
if (a != d) | ||
return; | ||
if (b != 0) | ||
return; | ||
clang_analyzer_printState(); | ||
(void)(a * b * c * d); | ||
return; | ||
} | ||
|
||
// CHECK: "equivalence_classes": [ | ||
// CHECK-NEXT: [ "reg_$0<int a>", "(reg_$0<int a>) + (reg_$1<int b>)", "reg_$2<int c>", "reg_$3<int d>" ], | ||
// CHECK-NEXT: [ "((reg_$0<int a>) + (reg_$1<int b>)) != (reg_$2<int c>)", "(reg_$0<int a>) != (reg_$2<int c>)" ] | ||
// CHECK-NEXT: ], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters