diff options
Diffstat (limited to 'clang/test/Analysis/copypaste/delete.cpp')
| -rw-r--r-- | clang/test/Analysis/copypaste/delete.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/clang/test/Analysis/copypaste/delete.cpp b/clang/test/Analysis/copypaste/delete.cpp new file mode 100644 index 00000000000..dc42c9c0595 --- /dev/null +++ b/clang/test/Analysis/copypaste/delete.cpp @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -analyze -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s + +// expected-no-diagnostics + +bool foo1(int x, int* a) { + if (x > 0) + return false; + else if (x < 0) + delete a; + return true; +} + +// Explicit global delete +bool foo2(int x, int* a) { + if (x > 0) + return false; + else if (x < 0) + ::delete a; + return true; +} + +// Array delete +bool foo3(int x, int* a) { + if (x > 0) + return false; + else if (x < 0) + delete[] a; + return true; +} |

