================
@@ -123,6 +123,13 @@ void VirtualCallChecker::checkPreCall(const CallEvent 
&Call,
   if (!ObState)
     return;
 
+  // If the class whose constructor/destructor we're in is marked final,
+  // virtual dispatch is safe because there can be no derived classes.
+  const auto *LCtx = C.getLocationContext();
+  const auto *CurMethod = dyn_cast_or_null<CXXMethodDecl>(LCtx->getDecl());
+  if (CurMethod && CurMethod->getParent()->hasAttr<FinalAttr>())
----------------
steakhal wrote:

Shouldn't this be just this:

```suggestion
  if (MD->getParent()->hasAttr<FinalAttr>())
```

Or maybe even better:
```suggestion
  if (MD->getParent()->isEffectivelyFinal())
```

https://github.com/llvm/llvm-project/pull/178654
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to