diff options
Diffstat (limited to 'clang/test/Analysis')
-rw-r--r-- | clang/test/Analysis/analyze-function-guide.cpp | 19 | ||||
-rw-r--r-- | clang/test/Analysis/analyzeOneFunction.cpp | 18 | ||||
-rw-r--r-- | clang/test/Analysis/analyzer-stats/entry-point-stats.cpp | 8 | ||||
-rw-r--r-- | clang/test/Analysis/csv2json.py | 7 |
4 files changed, 39 insertions, 13 deletions
diff --git a/clang/test/Analysis/analyze-function-guide.cpp b/clang/test/Analysis/analyze-function-guide.cpp index 96f10010..e260fc4 100644 --- a/clang/test/Analysis/analyze-function-guide.cpp +++ b/clang/test/Analysis/analyze-function-guide.cpp @@ -46,14 +46,17 @@ int fizzbuzz(int x, bool y) { // CHECK-ADVOCATE-DISPLAY-PROGRESS-NEXT: Pass the -analyzer-display-progress for tracking which functions are analyzed. // CHECK-ADVOCATE-DISPLAY-PROGRESS-NOT: For analyzing -// Same as the previous but syntax mode only. -// FIXME: This should have empty standard output. +// The user only enables syntax-only analysis, like `debug.DumpDominators`. +// `-analyze-function` should only match the given function. // -// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-config ipa=none \ +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.DumpDominators -analyzer-config ipa=none \ // RUN: -analyze-function='fizzbuzz(int, _Bool)' -x c++ \ // RUN: -triple x86_64-pc-linux-gnu 2>&1 %s \ -// RUN: | FileCheck %s -check-prefix=CHECK-EMPTY3 --allow-empty -// -// FIXME: This should have empty standard output. -// CHECK-EMPTY3: Every top-level function was skipped. -// CHECK-EMPTY3-NEXT: Pass the -analyzer-display-progress for tracking which functions are analyzed. +// RUN: | FileCheck %s -check-prefix=CHECK-SYNTAX-ONLY --allow-empty +// +// With syntax-only analysis, the function is found and analyzed, so no error message. +// CHECK-SYNTAX-ONLY: Immediate dominance tree (Node#,IDom#): +// CHECK-SYNTAX-ONLY-NEXT: (0,1) +// CHECK-SYNTAX-ONLY-NEXT: (1,2) +// CHECK-SYNTAX-ONLY-NEXT: (2,2) +// CHECK-SYNTAX-ONLY-NOT: Every top-level function was skipped. diff --git a/clang/test/Analysis/analyzeOneFunction.cpp b/clang/test/Analysis/analyzeOneFunction.cpp new file mode 100644 index 0000000..3a362df --- /dev/null +++ b/clang/test/Analysis/analyzeOneFunction.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s \ +// RUN: -analyze-function="Window::overloaded(int)" + +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s \ +// RUN: -analyze-function="c:@S@Window@F@overloaded#I#" + +// RUN: %clang_extdef_map %s | FileCheck %s +// CHECK: 27:c:@S@Window@F@overloaded#I# +// CHECK-NEXT: 27:c:@S@Window@F@overloaded#C# +// CHECK-NEXT: 27:c:@S@Window@F@overloaded#d# + +void clang_analyzer_warnIfReached(); + +struct Window { + void overloaded(double) { clang_analyzer_warnIfReached(); } // not analyzed, thus not reachable + void overloaded(char) { clang_analyzer_warnIfReached(); } // not analyzed, thus not reachable + void overloaded(int) { clang_analyzer_warnIfReached(); } // expected-warning {{REACHABLE}} +}; diff --git a/clang/test/Analysis/analyzer-stats/entry-point-stats.cpp b/clang/test/Analysis/analyzer-stats/entry-point-stats.cpp index 1ff31d1..9cbe045 100644 --- a/clang/test/Analysis/analyzer-stats/entry-point-stats.cpp +++ b/clang/test/Analysis/analyzer-stats/entry-point-stats.cpp @@ -5,7 +5,9 @@ // RUN: %csv2json "%t.csv" | FileCheck --check-prefix=CHECK %s // // CHECK: { -// CHECK-NEXT: "fib(unsigned int)": { +// CHECK-NEXT: "c:@F@fib#i#": { +// CHECK-NEXT: "File": "{{.*}}entry-point-stats.cpp", +// CHECK-NEXT: "DebugName": "fib(unsigned int)", // CHECK-NEXT: "NumBlocks": "{{[0-9]+}}", // CHECK-NEXT: "NumBlocksUnreachable": "{{[0-9]+}}", // CHECK-NEXT: "NumCTUSteps": "{{[0-9]+}}", @@ -40,7 +42,9 @@ // CHECK-NEXT: "MaxValidBugClassSize": "{{[0-9]+}}", // CHECK-NEXT: "PathRunningTime": "{{[0-9]+}}" // CHECK-NEXT: }, -// CHECK-NEXT: "main(int, char **)": { +// CHECK-NEXT: "c:@F@main#I#**C#": { +// CHECK-NEXT: "File": "{{.*}}entry-point-stats.cpp", +// CHECK-NEXT: "DebugName": "main(int, char **)", // CHECK-NEXT: "NumBlocks": "{{[0-9]+}}", // CHECK-NEXT: "NumBlocksUnreachable": "{{[0-9]+}}", // CHECK-NEXT: "NumCTUSteps": "{{[0-9]+}}", diff --git a/clang/test/Analysis/csv2json.py b/clang/test/Analysis/csv2json.py index 3c20d68..6e1aca9 100644 --- a/clang/test/Analysis/csv2json.py +++ b/clang/test/Analysis/csv2json.py @@ -44,7 +44,7 @@ def csv_to_json_dict(csv_filepath): """ try: with open(csv_filepath, "r", encoding="utf-8") as csvfile: - reader = csv.reader(csvfile) + reader = csv.reader(csvfile, skipinitialspace=True) # Read the header row (column names) try: @@ -58,12 +58,13 @@ def csv_to_json_dict(csv_filepath): json.dumps({}, indent=2) return - other_column_names = [name.strip() for name in header[1:]] + header_length = len(header) + other_column_names = header[1:] data_dict = {} for row in reader: - if len(row) != len(header): + if len(row) != header_length: raise csv.Error("Inconsistent CSV file") exit(1) |