Introduce initial transfer function support for __imag__ and __real__. We don't
have complex RValues yet, so this logic is only fully implemented when __imag__
and __real__ are used on non-complex types.
llvm-svn: 52501
diff --git a/clang/test/Analysis/complex.c b/clang/test/Analysis/complex.c
new file mode 100644
index 0000000..7561293
--- /dev/null
+++ b/clang/test/Analysis/complex.c
@@ -0,0 +1,17 @@
+// RUN: clang -checker-simple -verify %s
+
+#include <stdlib.h>
+
+int f1(int * p) {
+
+ // This branch should be infeasible
+ // because __imag__ p is 0.
+ if (!p && __imag__ (intptr_t) p)
+ *p = 1; // no-warning
+
+ // If p != 0 then this branch is feasible; otherwise it is not.
+ if (__real__ (intptr_t) p)
+ *p = 1; // no-warning
+
+ *p = 2; // expected-warning{{Dereference of null pointer}}
+}