[clang] [analyzer] Use dynamic type when invalidating by a member function call (PR #111138)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 24 04:02:13 PDT 2024


================
@@ -748,6 +747,22 @@ SVal CXXInstanceCall::getCXXThisVal() const {
   return ThisVal;
 }
 
+const CXXRecordDecl *CXXInstanceCall::getDeclForDynamicType() const {
+  const MemRegion *R = getCXXThisVal().getAsRegion();
+  if (!R)
+    return nullptr;
+
+  DynamicTypeInfo DynType = getDynamicTypeInfo(getState(), R);
+  if (!DynType.isValid())
+    return nullptr;
+
+  QualType Ty = DynType.getType()->getPointeeType();
+  if (Ty.isNull())
----------------
Xazax-hun wrote:

Sounds good! The assert message made me think that this was a global invariant, not specific to the call site. 

https://github.com/llvm/llvm-project/pull/111138


More information about the cfe-commits mailing list