summaryrefslogtreecommitdiffstats
path: root/test/Analysis/inlining/inline-defensive-checks.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/inlining/inline-defensive-checks.cpp')
-rw-r--r--test/Analysis/inlining/inline-defensive-checks.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/Analysis/inlining/inline-defensive-checks.cpp b/test/Analysis/inlining/inline-defensive-checks.cpp
new file mode 100644
index 0000000..37bccbd
--- /dev/null
+++ b/test/Analysis/inlining/inline-defensive-checks.cpp
@@ -0,0 +1,55 @@
+// 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() { }
+public:
+ int triggerderef() {
+ return 0;
+ }
+};
+ButterFly *getInP();
+class X{
+ ButterFly *p;
+ void setP(ButterFly *inP) {
+ if(inP)
+ ;
+ p = inP;
+ };
+ void subtest1() {
+ ButterFly *inP = getInP();
+ setP(inP);
+ }
+ int subtest2() {
+ int c = p->triggerderef(); // no-warning
+ return c;
+ }
+ int test() {
+ subtest1();
+ return subtest2();
+ }
+};
+
+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
+} \ No newline at end of file
OpenPOWER on IntegriCloud