================
@@ -123,6 +123,21 @@ void VirtualCallChecker::checkPreCall(const CallEvent 
&Call,
   if (!ObState)
     return;
 
+  // If we're directly inside the constructor/destructor of a final class,
+  // virtual dispatch is safe because there can be no derived classes.
+  // We only suppress when directly in the ctor/dtor, not in helper functions
+  // (which could be called from non-final classes), and not in base class
+  // ctors/dtors (which have broken vtables even when constructing/destroying
+  // a final derived class).
----------------
haoNoQ wrote:

```suggestion
  // We only suppress when directly in the derived class ctor/dtor and not in
  // base class ctors/dtors which have broken vtables even when constructing
  // or destroying a final derived class.
  // FIXME: We only suppress when directly in the ctor/dtor, not in arbitrary
  // helper functions that may be defined anywhere and called through an
  // arbitrary call stack. C.getLocationContext() does not always represent
  // the stack frame we should be looking at, which can incorrectly swing
  // this check in either direction.
  // FIXME: The method MD may be final even when the class isn't.
```

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