r202212 - [analyzer] NonNullParamChecker: don't freak out about nested transparent_unions.
Jordan Rose
jordan_rose at apple.com
Tue Feb 25 17:20:19 PST 2014
Author: jrose
Date: Tue Feb 25 19:20:19 2014
New Revision: 202212
URL: http://llvm.org/viewvc/llvm-project?rev=202212&view=rev
Log:
[analyzer] NonNullParamChecker: don't freak out about nested transparent_unions.
For now, just ignore them. Later, we could try looking through LazyCompoundVals,
but we at least shouldn't crash.
<rdar://problem/16153464>
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
cfe/trunk/test/Analysis/nonnull.m
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp?rev=202212&r1=202211&r2=202212&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp Tue Feb 25 19:20:19 2014
@@ -104,7 +104,9 @@ void NonNullParamChecker::checkPreCall(c
V = *CSV_I;
DV = V.getAs<DefinedSVal>();
assert(++CSV_I == CSV->end());
- if (!DV)
+ // FIXME: Handle (some_union){ some_other_union_val }, which turns into
+ // a LazyCompoundVal inside a CompoundVal.
+ if (!V.getAs<Loc>())
continue;
// Retrieve the corresponding expression.
if (const CompoundLiteralExpr *CE = dyn_cast<CompoundLiteralExpr>(ArgE))
Modified: cfe/trunk/test/Analysis/nonnull.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nonnull.m?rev=202212&r1=202211&r2=202212&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/nonnull.m (original)
+++ cfe/trunk/test/Analysis/nonnull.m Tue Feb 25 19:20:19 2014
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -w -verify %s
@interface MyObject
- (void)takePointer:(void *)ptr __attribute__((nonnull(1)));
@@ -30,3 +30,48 @@ void testSubclassArg(int *p, Subclass *o
[obj takePointerArg:p]; // expected-warning{{nonnull}}
}
+
+union rdar16153464_const_cp_t {
+ const struct rdar16153464_cczp *zp;
+ const struct rdar16153464_cczp_prime *prime;
+} __attribute__((transparent_union));
+
+struct rdar16153464_header {
+ union rdar16153464_const_cp_t cp;
+ unsigned char pad[16 - sizeof(union rdar16153464_const_cp_t *)];
+} __attribute__((aligned(16)));
+
+
+struct rdar16153464_full_ctx {
+ struct rdar16153464_header hdr;
+} __attribute__((aligned(16)));
+
+
+struct rdar16153464_pub_ctx {
+ struct rdar16153464_header hdr;
+} __attribute__((aligned(16)));
+
+
+union rdar16153464_full_ctx_t {
+ struct rdar16153464_full_ctx *_full;
+ struct rdar16153464_header *hdr;
+ struct rdar16153464_body *body;
+ struct rdar16153464_public *pub;
+} __attribute__((transparent_union));
+
+union rdar16153464_pub_ctx_t {
+ struct rdar16153464_pub_ctx *_pub;
+ struct rdar16153464_full_ctx *_full;
+ struct rdar16153464_header *hdr;
+ struct rdar16153464_body *body;
+ struct rdar16153464_public *pub;
+ union rdar16153464_full_ctx_t innert;
+} __attribute__((transparent_union));
+
+int rdar16153464(union rdar16153464_full_ctx_t inner)
+{
+ extern void rdar16153464_check(union rdar16153464_pub_ctx_t outer) __attribute((nonnull(1)));
+ rdar16153464_check((union rdar16153464_pub_ctx_t){ .innert = inner }); // no-warning
+ rdar16153464_check(inner); // no-warning
+ rdar16153464_check(0); // expected-warning{{nonnull}}
+}
More information about the cfe-commits
mailing list