Marius =?utf-8?q?Dörner?= <[email protected]>,
Marius =?utf-8?q?Dörner?= <[email protected]>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/[email protected]>
================
@@ -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)) {
+ const Expr *E = S.Current->getExpr(OpPC);
+ APValue V = TypePtr.toAPValue(S.getASTContext());
+ QualType TT = S.getASTContext().getLValueReferenceType(DynamicType);
----------------
mariusdr wrote:
The output is slightly different because toDiagnosticString() (~
APValue::getAsString(V, TypePtr.getType()) adds a '&' prefix to the output
while the code above does not, because the input QualType is not a reference
type ref:
https://github.com/llvm/llvm-project/blob/6a7aec12ad359476c2c4dadce05dfef384187901/clang/lib/AST/APValue.cpp#L819-L821
we would get messages like
```
note: virtual function called on object '&k' whose dynamic type is not constant
```
while the other interpreter outputs
```
note: virtual function called on object 'k' whose dynamic type is not constant
```
https://github.com/llvm/llvm-project/pull/158502
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits