diff options
Diffstat (limited to 'test/Analysis/copypaste')
-rw-r--r-- | test/Analysis/copypaste/autogenerated_automoc.cpp | 19 | ||||
-rw-r--r-- | test/Analysis/copypaste/dbus_autogenerated.cpp | 19 | ||||
-rw-r--r-- | test/Analysis/copypaste/moc_autogenerated.cpp | 19 | ||||
-rw-r--r-- | test/Analysis/copypaste/not-autogenerated.cpp | 14 | ||||
-rw-r--r-- | test/Analysis/copypaste/ui_autogenerated.cpp | 19 |
5 files changed, 90 insertions, 0 deletions
diff --git a/test/Analysis/copypaste/autogenerated_automoc.cpp b/test/Analysis/copypaste/autogenerated_automoc.cpp new file mode 100644 index 0000000000000..55963c4545c9a --- /dev/null +++ b/test/Analysis/copypaste/autogenerated_automoc.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:IgnoredFilesPattern="moc_|.*_automoc.cpp" -verify %s + +// Because files that have `_automoc.' in their names are most likely autogenerated, +// we suppress copy-paste warnings here. + +// expected-no-diagnostics + +void f1() { + int *p1 = new int[1]; + int *p2 = new int[1]; + if (p1) { + delete [] p1; + p1 = nullptr; + } + if (p2) { + delete [] p1; // no-warning + p2 = nullptr; + } +} diff --git a/test/Analysis/copypaste/dbus_autogenerated.cpp b/test/Analysis/copypaste/dbus_autogenerated.cpp new file mode 100644 index 0000000000000..1824375658130 --- /dev/null +++ b/test/Analysis/copypaste/dbus_autogenerated.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:IgnoredFilesPattern="moc_|dbus_|.*_automoc" -verify %s + +// Because files that have `dbus_' in their names are most likely autogenerated, +// we suppress copy-paste warnings here. + +// expected-no-diagnostics + +void f1() { + int *p1 = new int[1]; + int *p2 = new int[1]; + if (p1) { + delete [] p1; + p1 = nullptr; + } + if (p2) { + delete [] p1; // no-warning + p2 = nullptr; + } +} diff --git a/test/Analysis/copypaste/moc_autogenerated.cpp b/test/Analysis/copypaste/moc_autogenerated.cpp new file mode 100644 index 0000000000000..626fe2a3dd070 --- /dev/null +++ b/test/Analysis/copypaste/moc_autogenerated.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:IgnoredFilesPattern="moc_|.*_automoc" -verify %s + +// Because files that have `moc_' in their names are most likely autogenerated, +// we suppress copy-paste warnings here. + +// expected-no-diagnostics + +void f1() { + int *p1 = new int[1]; + int *p2 = new int[1]; + if (p1) { + delete [] p1; + p1 = nullptr; + } + if (p2) { + delete [] p1; // no-warning + p2 = nullptr; + } +} diff --git a/test/Analysis/copypaste/not-autogenerated.cpp b/test/Analysis/copypaste/not-autogenerated.cpp new file mode 100644 index 0000000000000..765e7aaf2aab6 --- /dev/null +++ b/test/Analysis/copypaste/not-autogenerated.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:IgnoredFilesPattern="moc_|ui_|dbus_|.*_automoc" -verify %s + +void f1() { + int *p1 = new int[1]; + int *p2 = new int[1]; + if (p1) { + delete [] p1; // expected-note{{Similar code using 'p1' here}} + p1 = nullptr; + } + if (p2) { + delete [] p1; // expected-warning{{Potential copy-paste error; did you really mean to use 'p1' here?}} + p2 = nullptr; + } +} diff --git a/test/Analysis/copypaste/ui_autogenerated.cpp b/test/Analysis/copypaste/ui_autogenerated.cpp new file mode 100644 index 0000000000000..a08c33fe9e2a0 --- /dev/null +++ b/test/Analysis/copypaste/ui_autogenerated.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:IgnoredFilesPattern="moc_|ui_|.*_automoc" -verify %s + +// Because files that have `ui_' in their names are most likely autogenerated, +// we suppress copy-paste warnings here. + +// expected-no-diagnostics + +void f1() { + int *p1 = new int[1]; + int *p2 = new int[1]; + if (p1) { + delete [] p1; + p1 = nullptr; + } + if (p2) { + delete [] p1; // no-warning + p2 = nullptr; + } +} |