aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/inlining
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2013-03-15 01:15:12 +0000
committerAnna Zaks <ganna@apple.com>2013-03-15 01:15:12 +0000
commitdc9c160dede7e2f5cc11755db6aaa57e7fccbcec (patch)
tree731ed969fc71cad6130f88082828275664b703d3 /test/Analysis/inlining
parentd92277928eefcf958080707ed6e154f406a5d054 (diff)
[analyzer] Teach trackNullOrUndef to look through ternary operators
Allows the suppression visitors trigger more often. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177137 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/inlining')
-rw-r--r--test/Analysis/inlining/false-positive-suppression.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/Analysis/inlining/false-positive-suppression.c b/test/Analysis/inlining/false-positive-suppression.c
index bed64f1837..fbdb1650ff 100644
--- a/test/Analysis/inlining/false-positive-suppression.c
+++ b/test/Analysis/inlining/false-positive-suppression.c
@@ -191,3 +191,39 @@ void testAlwaysReturnNull(void *input) {
#endif
}
+int derefArg(int *p) {
+ return *p;
+#ifndef SUPPRESSED
+ // expected-warning@-2 {{Dereference of null pointer}}
+#endif
+}
+void ternaryArg(char cond) {
+ static int x;
+ derefArg(cond ? &x : getNull());
+}
+
+int derefAssignment(int *p) {
+ return *p;
+#ifndef SUPPRESSED
+ // expected-warning@-2 {{Dereference of null pointer}}
+#endif
+}
+void ternaryAssignment(char cond) {
+ static int x;
+ int *p = cond ? &x : getNull();
+ derefAssignment(p);
+}
+
+int *retNull(char cond) {
+ static int x;
+ return cond ? &x : getNull();
+}
+int ternaryRetNull(char cond) {
+ int *p = retNull(cond);
+ return *p;
+#ifndef SUPPRESSED
+ // expected-warning@-2 {{Dereference of null pointer}}
+#endif
+}
+
+