diff options
| author | Alexander Shaposhnikov <shal1t712@gmail.com> | 2017-04-12 22:00:13 +0000 |
|---|---|---|
| committer | Alexander Shaposhnikov <shal1t712@gmail.com> | 2017-04-12 22:00:13 +0000 |
| commit | 5f24c12dc4cfddc598fa8804f2511de391d14ebf (patch) | |
| tree | 005c550199fd6221f38678f7b480038693df4f82 | |
| parent | 0d0d6c2f2515b20ff287107c8d1a07c920558bf1 (diff) | |
| download | bcm5719-llvm-5f24c12dc4cfddc598fa8804f2511de391d14ebf.tar.gz bcm5719-llvm-5f24c12dc4cfddc598fa8804f2511de391d14ebf.zip | |
[analyzer] Add a check for IvarRegion in getExtraInvalidatedValues
This diff adds a defensive check in getExtraInvalidatedValues
for the case when there are no regions for the ivar associated with
a property. Corresponding test case added.
Test plan:
make check-clang
make check-clang-analysis
llvm-svn: 300114
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/CallEvent.cpp | 12 | ||||
| -rw-r--r-- | clang/test/Analysis/properties.m | 16 |
2 files changed, 23 insertions, 5 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp index ef824b8a3b1..ee761689f47 100644 --- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp +++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp @@ -695,13 +695,15 @@ void ObjCMethodCall::getExtraInvalidatedValues( if (const ObjCPropertyDecl *PropDecl = getAccessedProperty()) { if (const ObjCIvarDecl *PropIvar = PropDecl->getPropertyIvarDecl()) { SVal IvarLVal = getState()->getLValue(PropIvar, getReceiverSVal()); - const MemRegion *IvarRegion = IvarLVal.getAsRegion(); - ETraits->setTrait( + if (const MemRegion *IvarRegion = IvarLVal.getAsRegion()) { + ETraits->setTrait( IvarRegion, RegionAndSymbolInvalidationTraits::TK_DoNotInvalidateSuperRegion); - ETraits->setTrait(IvarRegion, - RegionAndSymbolInvalidationTraits::TK_SuppressEscape); - Values.push_back(IvarLVal); + ETraits->setTrait( + IvarRegion, + RegionAndSymbolInvalidationTraits::TK_SuppressEscape); + Values.push_back(IvarLVal); + } return; } } diff --git a/clang/test/Analysis/properties.m b/clang/test/Analysis/properties.m index 542a339cd6b..e792bb2e6ba 100644 --- a/clang/test/Analysis/properties.m +++ b/clang/test/Analysis/properties.m @@ -987,5 +987,21 @@ void testOpaqueConsistency(OpaqueIntWrapper *w) { } @end + +@interface Wrapper +@property(nonatomic, readonly) int value; +@end + +@implementation Wrapper +@synthesize value; +@end + +void testNoCrashWhenAccessPropertyAndThereAreNoDirectBindingsAtAll() { + union { + Wrapper *wrapper; + } u = { 0 }; + [u.wrapper value]; +} + #endif // non-ARC |

