summaryrefslogtreecommitdiff
path: root/test/Analysis/html_diagnostics
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/html_diagnostics')
-rw-r--r--test/Analysis/html_diagnostics/relevant_lines/goto.c13
-rw-r--r--test/Analysis/html_diagnostics/relevant_lines/header.h12
-rw-r--r--test/Analysis/html_diagnostics/relevant_lines/macros_same_file.c15
-rw-r--r--test/Analysis/html_diagnostics/relevant_lines/multifile.c14
-rw-r--r--test/Analysis/html_diagnostics/relevant_lines/multiline_func_def.c16
-rw-r--r--test/Analysis/html_diagnostics/relevant_lines/notexecutedlines.c12
-rw-r--r--test/Analysis/html_diagnostics/relevant_lines/objcmethods.m19
-rw-r--r--test/Analysis/html_diagnostics/relevant_lines/simple_conditional.c13
-rw-r--r--test/Analysis/html_diagnostics/relevant_lines/switch.c20
-rw-r--r--test/Analysis/html_diagnostics/relevant_lines/switch_default.c20
-rw-r--r--test/Analysis/html_diagnostics/relevant_lines/unused_header.c19
11 files changed, 173 insertions, 0 deletions
diff --git a/test/Analysis/html_diagnostics/relevant_lines/goto.c b/test/Analysis/html_diagnostics/relevant_lines/goto.c
new file mode 100644
index 0000000000000..fc90f1334f076
--- /dev/null
+++ b/test/Analysis/html_diagnostics/relevant_lines/goto.c
@@ -0,0 +1,13 @@
+int goto_test(int input) {
+ int *p = 0;
+ if (input)
+ goto mylabel;
+ return 0;
+mylabel:
+ return *p;
+}
+
+// RUN: rm -rf %t.output
+// RUN: %clang_analyze_cc1 -analyze -analyzer-checker=core -analyzer-output html -o %t.output %s
+// RUN: cat %t.output/* | FileCheck %s --match-full-lines
+// CHECK: var relevant_lines = {"1": {"1": 1, "2": 1, "3": 1, "4": 1, "6": 1, "7": 1}};
diff --git a/test/Analysis/html_diagnostics/relevant_lines/header.h b/test/Analysis/html_diagnostics/relevant_lines/header.h
new file mode 100644
index 0000000000000..579b66a1cb316
--- /dev/null
+++ b/test/Analysis/html_diagnostics/relevant_lines/header.h
@@ -0,0 +1,12 @@
+#define deref(X) (*X)
+
+char helper(
+ char *out,
+ int doDereference) {
+ if (doDereference) {
+ return deref(out);
+ } else {
+ return 'x';
+ }
+ return 'c';
+}
diff --git a/test/Analysis/html_diagnostics/relevant_lines/macros_same_file.c b/test/Analysis/html_diagnostics/relevant_lines/macros_same_file.c
new file mode 100644
index 0000000000000..5b3556526add2
--- /dev/null
+++ b/test/Analysis/html_diagnostics/relevant_lines/macros_same_file.c
@@ -0,0 +1,15 @@
+#define deref(X) (*X)
+
+int f(int coin) {
+ if (coin) {
+ int *x = 0;
+ return deref(x);
+ } else {
+ return 0;
+ }
+}
+
+// RUN: rm -rf %t.output
+// RUN: %clang_analyze_cc1 -analyze -analyzer-checker=core -analyzer-output html -o %t.output %s
+// RUN: cat %t.output/* | FileCheck %s --match-full-lines
+// CHECK: var relevant_lines = {"1": {"3": 1, "4": 1, "5": 1, "6": 1}};
diff --git a/test/Analysis/html_diagnostics/relevant_lines/multifile.c b/test/Analysis/html_diagnostics/relevant_lines/multifile.c
new file mode 100644
index 0000000000000..3abffd609b5be
--- /dev/null
+++ b/test/Analysis/html_diagnostics/relevant_lines/multifile.c
@@ -0,0 +1,14 @@
+#include "header.h"
+
+int f(int coin) {
+ char *p = 0;
+ if (coin) {
+ return helper(p, coin);
+ }
+ return 0;
+}
+
+// RUN: rm -rf %t.output
+// RUN: %clang_analyze_cc1 -analyze -analyzer-checker=core -analyzer-output html -o %t.output %s
+// RUN: cat %t.output/* | FileCheck %s --match-full-lines
+// CHECK: var relevant_lines = {"1": {"3": 1, "4": 1, "5": 1, "6": 1}, "3": {"3": 1, "4": 1, "5": 1, "6": 1, "7": 1}};
diff --git a/test/Analysis/html_diagnostics/relevant_lines/multiline_func_def.c b/test/Analysis/html_diagnostics/relevant_lines/multiline_func_def.c
new file mode 100644
index 0000000000000..35158a46868ca
--- /dev/null
+++ b/test/Analysis/html_diagnostics/relevant_lines/multiline_func_def.c
@@ -0,0 +1,16 @@
+int f(
+ int coin,
+ int paramA,
+ int paramB) {
+ if (coin) {
+ int *x = 0;
+ return *x;
+ } else {
+ return 0;
+ }
+}
+
+// RUN: rm -rf %t.output
+// RUN: %clang_analyze_cc1 -analyze -analyzer-checker=core -analyzer-output html -o %t.output %s
+// RUN: cat %t.output/* | FileCheck %s --match-full-lines
+// CHECK: var relevant_lines = {"1": {"1": 1, "2": 1, "3": 1, "4": 1, "5": 1, "6": 1, "7": 1}};
diff --git a/test/Analysis/html_diagnostics/relevant_lines/notexecutedlines.c b/test/Analysis/html_diagnostics/relevant_lines/notexecutedlines.c
new file mode 100644
index 0000000000000..3c723aa93349e
--- /dev/null
+++ b/test/Analysis/html_diagnostics/relevant_lines/notexecutedlines.c
@@ -0,0 +1,12 @@
+int f() {
+ int zzz = 200;
+ zzz += 100;
+ return 0;
+}
+
+// Show line with the warning even if it wasn't executed (e.g. warning given
+// by path-insensitive analysis).
+// RUN: rm -rf %t.output
+// RUN: %clang_analyze_cc1 -analyze -analyzer-checker=core,deadcode -analyzer-output html -o %t.output %s
+// RUN: cat %t.output/* | FileCheck %s --match-full-lines
+// CHECK: var relevant_lines = {"1": {"3": 1}};
diff --git a/test/Analysis/html_diagnostics/relevant_lines/objcmethods.m b/test/Analysis/html_diagnostics/relevant_lines/objcmethods.m
new file mode 100644
index 0000000000000..41a4c1d2e0973
--- /dev/null
+++ b/test/Analysis/html_diagnostics/relevant_lines/objcmethods.m
@@ -0,0 +1,19 @@
+@interface I
+- (int)func;
+@end
+
+@implementation I
+- (int)func:(int *)param {
+ return *param;
+}
+@end
+
+void foo(I *i) {
+ int *x = 0;
+ [i func:x];
+}
+
+// RUN: rm -rf %t.output
+// RUN: %clang_analyze_cc1 -analyze -analyzer-checker=core -analyzer-output html -o %t.output -Wno-objc-root-class %s
+// RUN: cat %t.output/* | FileCheck %s
+// CHECK: var relevant_lines = {"1": {"6": 1, "7": 1, "11": 1, "12": 1, "13": 1}};
diff --git a/test/Analysis/html_diagnostics/relevant_lines/simple_conditional.c b/test/Analysis/html_diagnostics/relevant_lines/simple_conditional.c
new file mode 100644
index 0000000000000..769859dea5efc
--- /dev/null
+++ b/test/Analysis/html_diagnostics/relevant_lines/simple_conditional.c
@@ -0,0 +1,13 @@
+int f(int coin) {
+ if (coin) {
+ int *x = 0;
+ return *x;
+ } else {
+ return 0;
+ }
+}
+
+// RUN: rm -rf %t.output
+// RUN: %clang_analyze_cc1 -analyze -analyzer-checker=core -analyzer-output html -o %t.output %s
+// RUN: cat %t.output/* | FileCheck %s --match-full-lines
+// CHECK: var relevant_lines = {"1": {"1": 1, "2": 1, "3": 1, "4": 1}};
diff --git a/test/Analysis/html_diagnostics/relevant_lines/switch.c b/test/Analysis/html_diagnostics/relevant_lines/switch.c
new file mode 100644
index 0000000000000..e9032cdece9dc
--- /dev/null
+++ b/test/Analysis/html_diagnostics/relevant_lines/switch.c
@@ -0,0 +1,20 @@
+enum E {
+ A, B, C
+};
+
+int f(enum E input) {
+ int *x = 0;
+ switch (input) {
+ case A:
+ return 1;
+ case B:
+ return 0;
+ case C:
+ return *x;
+ }
+}
+
+// RUN: rm -rf %t.output
+// RUN: %clang_analyze_cc1 -analyze -analyzer-checker=core -analyzer-output html -o %t.output %s
+// RUN: cat %t.output/* | FileCheck %s --match-full-lines
+// CHECK: var relevant_lines = {"1": {"5": 1, "6": 1, "7": 1, "12": 1, "13": 1}};
diff --git a/test/Analysis/html_diagnostics/relevant_lines/switch_default.c b/test/Analysis/html_diagnostics/relevant_lines/switch_default.c
new file mode 100644
index 0000000000000..b14e3f9fa8fd6
--- /dev/null
+++ b/test/Analysis/html_diagnostics/relevant_lines/switch_default.c
@@ -0,0 +1,20 @@
+enum E {
+ A, B, C
+};
+
+int f(enum E input) {
+ int *x = 0;
+ switch (input) {
+ case A:
+ return 1;
+ case B:
+ return 0;
+ default:
+ return *x;
+ }
+}
+
+// RUN: rm -rf %t.output
+// RUN: %clang_analyze_cc1 -analyze -analyzer-checker=core -analyzer-output html -o %t.output %s
+// RUN: cat %t.output/* | FileCheck %s --match-full-lines
+// CHECK: var relevant_lines = {"1": {"5": 1, "6": 1, "7": 1, "12": 1, "13": 1}};
diff --git a/test/Analysis/html_diagnostics/relevant_lines/unused_header.c b/test/Analysis/html_diagnostics/relevant_lines/unused_header.c
new file mode 100644
index 0000000000000..4b77c651eddd9
--- /dev/null
+++ b/test/Analysis/html_diagnostics/relevant_lines/unused_header.c
@@ -0,0 +1,19 @@
+#include "header.h"
+
+int f(int coin) {
+ if (coin) {
+ int *x = 0;
+ return *x;
+ } else {
+ return 0;
+ }
+}
+
+int v(int coin) {
+ return coin;
+}
+
+// RUN: rm -rf %t.output
+// RUN: %clang_analyze_cc1 -analyze -analyzer-checker=core -analyzer-output html -o %t.output %s
+// RUN: cat %t.output/* | FileCheck %s --match-full-lines
+// CHECK: var relevant_lines = {"1": {"3": 1, "4": 1, "5": 1, "6": 1}};