aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/inlining/inline-defensive-checks.cpp
diff options
context:
space:
mode:
authorEli Bendersky <eliben@chromium.org>2013-07-15 16:08:08 -0700
committerEli Bendersky <eliben@chromium.org>2013-07-15 16:08:08 -0700
commite789858899a7b36caf11b371a97411a1582a482b (patch)
treee8c28b178b32010f73b477b3c65b5ff74437530c /test/Analysis/inlining/inline-defensive-checks.cpp
parent99a5501f5ae5b75017dfc386d4abf648234e85df (diff)
parent20c7d45a4da9f58ad805ad1d37f92fe7dc232ec8 (diff)
Merge commit '20c7d45a4da9f58ad805ad1d37f92fe7dc232ec8'
Conflicts: lib/CodeGen/ItaniumCXXABI.cpp
Diffstat (limited to 'test/Analysis/inlining/inline-defensive-checks.cpp')
-rw-r--r--test/Analysis/inlining/inline-defensive-checks.cpp43
1 files changed, 42 insertions, 1 deletions
diff --git a/test/Analysis/inlining/inline-defensive-checks.cpp b/test/Analysis/inlining/inline-defensive-checks.cpp
index c77961d03c..b69c535657 100644
--- a/test/Analysis/inlining/inline-defensive-checks.cpp
+++ b/test/Analysis/inlining/inline-defensive-checks.cpp
@@ -1,6 +1,12 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
// expected-no-diagnostics
+extern void __assert_fail (__const char *__assertion, __const char *__file,
+ unsigned int __line, __const char *__function)
+__attribute__ ((__noreturn__));
+#define assert(expr) \
+((expr) ? (void)(0) : __assert_fail (#expr, __FILE__, __LINE__, __func__))
+
class ButterFly {
private:
ButterFly() { }
@@ -29,4 +35,39 @@ class X{
subtest1();
return subtest2();
}
-}; \ No newline at end of file
+};
+
+typedef const int *Ty;
+extern
+Ty notNullArg(Ty cf) __attribute__((nonnull));
+typedef const void *CFTypeRef;
+extern Ty getTyVal();
+inline void radar13224271_callee(Ty def, Ty& result ) {
+ result = def;
+ // Clearly indicates that result cannot be 0 if def is not NULL.
+ assert( (result != 0) || (def == 0) );
+}
+void radar13224271_caller()
+{
+ Ty value;
+ radar13224271_callee(getTyVal(), value );
+ notNullArg(value); // no-warning
+}
+
+struct Foo {
+ int *ptr;
+ Foo(int *p) {
+ *p = 1; // no-warning
+ }
+};
+void idc(int *p3) {
+ if (p3)
+ ;
+}
+int *retNull() {
+ return 0;
+}
+void test(int *p1, int *p2) {
+ idc(p1);
+ Foo f(p1);
+} \ No newline at end of file