[clang] [clang][bytecode] Assert on virtual func call from array elem (PR #158502)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 23 06:53:10 PDT 2025


Marius =?utf-8?q?Dörner?= <marius.doerner1 at icloud.com>,
Marius =?utf-8?q?Dörner?= <marius.doerner1 at icloud.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/158502 at github.com>


================
@@ -1636,6 +1639,33 @@ bool Call(InterpState &S, CodePtr OpPC, const Function *Func,
   return true;
 }
 
+static bool GetDynamicDecl(InterpState &S, CodePtr OpPC, Pointer TypePtr,
+                           const CXXRecordDecl *&DynamicDecl) {
+  while (TypePtr.isBaseClass())
+    TypePtr = TypePtr.getBase();
+
+  QualType DynamicType = TypePtr.getType();
+  if (DynamicType->isPointerType() || DynamicType->isReferenceType()) {
+    DynamicDecl = DynamicType->getPointeeCXXRecordDecl();
+  } else if (DynamicType->isArrayType()) {
+    const Type *ElemType = DynamicType->getPointeeOrArrayElementType();
+    assert(ElemType);
+    DynamicDecl = ElemType->getAsCXXRecordDecl();
+  } else {
+    DynamicDecl = DynamicType->getAsCXXRecordDecl();
+  }
+
+  if (!CheckConstant(S, OpPC, TypePtr, true)) {
----------------
tbaederr wrote:

So what is actually the relevant part of `CheckConstant`? Is it just the call to `QualType::isConstant()`?

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


More information about the cfe-commits mailing list