summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorGeorge Karpenkov <ekarpenkov@apple.com>2018-01-10 01:22:14 +0000
committerGeorge Karpenkov <ekarpenkov@apple.com>2018-01-10 01:22:14 +0000
commit77dfbf21d1bc2adbfcbcb4e8f71e732764a6366a (patch)
treea942327a321978d2540f8a083cc38c7d0c59c526 /clang/test
parent5fa274bea4bac8f8e17908b4cf3114f9ea25a673 (diff)
downloadbcm5719-llvm-77dfbf21d1bc2adbfcbcb4e8f71e732764a6366a.tar.gz
bcm5719-llvm-77dfbf21d1bc2adbfcbcb4e8f71e732764a6366a.zip
[analyzer] suppress nullability inference from a macro when result is used in another macro
The current code used to not suppress the report, if the dereference was performed in a macro, assuming it is that same macro. However, the assumption might not be correct, and XNU has quite a bit of code where dereference is actually performed in a different macro. As the code uses macro name and not a unique identifier it might be fragile, but in a worst-case scenario we would simply emit an extra diagnostic. rdar://36160245 Differential Revision: https://reviews.llvm.org/D41749 llvm-svn: 322149
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Analysis/inlining/false-positive-suppression.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/test/Analysis/inlining/false-positive-suppression.c b/clang/test/Analysis/inlining/false-positive-suppression.c
index 4931695ef12..5f613e12c2f 100644
--- a/clang/test/Analysis/inlining/false-positive-suppression.c
+++ b/clang/test/Analysis/inlining/false-positive-suppression.c
@@ -163,6 +163,7 @@ void testNestedDisjunctiveMacro2(int *p, int *q) {
}
+
// Here the check is entirely in non-macro code even though the code itself
// is a macro argument.
#define MACRO_DO_IT(a) (a)
@@ -171,6 +172,15 @@ void testErrorInArgument(int *p) {
(void)i;
}
+// No warning should be emitted if dereference is performed from a different
+// macro.
+#define MACRO_CHECK(a) if (a) {}
+#define MACRO_DEREF(a) (*a)
+int testDifferentMacro(int *p) {
+ MACRO_CHECK(p);
+ return MACRO_DEREF(p); // no-warning
+}
+
// --------------------------
// "Suppression suppression"
// --------------------------
OpenPOWER on IntegriCloud