diff options
author | Artem Dergachev <artem.dergachev@gmail.com> | 2019-12-06 13:20:36 -0800 |
---|---|---|
committer | Artem Dergachev <artem.dergachev@gmail.com> | 2019-12-06 13:24:20 -0800 |
commit | 040c39d50fb9c60de9020caf86e1a1fccfd6f861 (patch) | |
tree | f71411bcbe7437b20de972110f345c3913acec63 | |
parent | d5abaaf140ac7f6d59ac11c0ecbdb8fa93972bf6 (diff) | |
download | bcm5719-llvm-040c39d50fb9c60de9020caf86e1a1fccfd6f861.tar.gz bcm5719-llvm-040c39d50fb9c60de9020caf86e1a1fccfd6f861.zip |
[analyzer] Fix false positive on introspection of a block's internal layout.
When implementation of the block runtime is available, we should not
warn that block layout fields are uninitialized simply because they're
on the stack.
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/RegionStore.cpp | 3 | ||||
-rw-r--r-- | clang/test/Analysis/blocks.m | 9 |
2 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp index 5d2ef59e2d6..4797f564a83 100644 --- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp +++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -1951,7 +1951,8 @@ RegionStoreManager::getBindingForFieldOrElementCommon(RegionBindingsConstRef B, if (hasSymbolicIndex) return UnknownVal(); - if (!hasPartialLazyBinding) + // Additionally allow introspection of a block's internal layout. + if (!hasPartialLazyBinding && !isa<BlockDataRegion>(R->getBaseRegion())) return UndefinedVal(); } diff --git a/clang/test/Analysis/blocks.m b/clang/test/Analysis/blocks.m index 98d0f8a2eba..a21a605ffa6 100644 --- a/clang/test/Analysis/blocks.m +++ b/clang/test/Analysis/blocks.m @@ -47,6 +47,10 @@ typedef struct __aslmsg *aslmsg; aslclient asl_open(const char *ident, const char *facility, uint32_t opts); int asl_log(aslclient asl, aslmsg msg, int level, const char *format, ...) __attribute__((__format__ (__printf__, 4, 5))); +struct Block_layout { + int flags; +}; + //===----------------------------------------------------------------------===// // Begin actual test cases. //===----------------------------------------------------------------------===// @@ -241,3 +245,8 @@ void call_block_with_fewer_arguments() { b(); // expected-warning {{Block taking 1 argument is called with fewer (0)}} } #endif + +int getBlockFlags() { + int x = 0; + return ((struct Block_layout *)^{ (void)x; })->flags; // no-warning +} |