Commit 69993350 authored by Simon Pilgrim's avatar Simon Pilgrim
Browse files

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.
parent d9bf79f4
Loading
Loading
Loading
Loading
+8 −10
Original line number Diff line number Diff line
@@ -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;
    }
    }

    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;
    }