ObjCMethodDecl::findPropertyDecl - fix static analyzer null dereference warnings. NFCI.

All paths dereference the ClassDecl pointer, so use a cast<> instead of dyn_cast<>, assert that its not null and remove the remaining null tests.
This commit is contained in:
Simon Pilgrim 2020-03-12 15:36:33 +00:00
parent d9bf79f4e9
commit 69993350ae
1 changed files with 8 additions and 10 deletions

View File

@ -1361,25 +1361,23 @@ ObjCMethodDecl::findPropertyDecl(bool CheckOverrides) const {
return Found;
} else {
// Determine whether the container is a class.
ClassDecl = dyn_cast<ObjCInterfaceDecl>(Container);
ClassDecl = cast<ObjCInterfaceDecl>(Container);
}
assert(ClassDecl && "Failed to find main class");
// If we have a class, check its visible extensions.
if (ClassDecl) {
for (const auto *Ext : ClassDecl->visible_extensions()) {
if (Ext == Container)
continue;
if (const auto *Found = findMatchingProperty(Ext))
return Found;
}
for (const auto *Ext : ClassDecl->visible_extensions()) {
if (Ext == Container)
continue;
if (const auto *Found = findMatchingProperty(Ext))
return Found;
}
assert(isSynthesizedAccessorStub() && "expected an accessor stub");
for (const auto *Cat : ClassDecl->known_categories()) {
if (Cat == Container)
continue;
if (const auto *Found = findMatchingProperty(Cat))
return Found;
}