]> granicus.if.org Git - clang/commitdiff
Static analysis test case for noreturn on exceptions.
authorTed Kremenek <kremenek@apple.com>
Fri, 2 May 2008 17:13:14 +0000 (17:13 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 2 May 2008 17:13:14 +0000 (17:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50580 91177308-0d34-0410-b5e6-96231b3b80d8

test/Analysis-Apple/NoReturn.m [new file with mode: 0644]

diff --git a/test/Analysis-Apple/NoReturn.m b/test/Analysis-Apple/NoReturn.m
new file mode 100644 (file)
index 0000000..6d53003
--- /dev/null
@@ -0,0 +1,36 @@
+// RUN: clang -checker-simple -verify %s
+// RUN: clang -checker-cfref -verify %s
+
+
+#include <Foundation/NSException.h>
+#include <Foundation/NSString.h>
+
+int* f1(int *x, NSString* s) {
+  
+  if (x) ++x;
+  
+  [NSException raise:@"Blah" format:[NSString stringWithFormat:@"Blah %@", s]];
+  
+  return *x; // no-warning
+}
+
+int* f2(int *x, ...) {
+  
+  if (x) ++x;
+  va_list alist;
+  va_start(alist, x);
+  
+  [NSException raise:@"Blah" format:@"Blah %@" arguments:alist];
+  
+  return *x; // no-warning
+}
+
+int *f3(int* x) {
+  
+  if (x) ++x;
+  
+  [[NSException exceptionWithName:@"My Exception" reason:@"Want to test exceptions." userInfo:nil] raise];
+
+  return *x; // no-warning
+}
+