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)) {
----------------
mariusdr wrote:
`DynamicType.isConstant()` would reject valid code like
```
struct A {
constexpr virtual void foo(int &a) {
a = 1;
}
};
constexpr int m() {
A b;
int a;
b.foo(a);
return a;
}
static_assert(m() == 1, "");
```
here `TypePtr.isStatic()` is false so `CheckConstant()` returns early but I'm
not sure if it is sufficient to only check those two things.
https://github.com/llvm/llvm-project/pull/158502
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits