================
@@ -1334,3 +1334,63 @@ mlir::Value CIRGenFunction::emitDynamicCast(Address
thisAddr,
return cgm.getCXXABI().emitDynamicCast(*this, loc, srcRecordTy, destRecordTy,
destCirTy, isRefCast, thisAddr);
}
+
+static mlir::Value emitCXXTypeidFromVTable(CIRGenFunction &cgf, const Expr *e,
+ mlir::Type typeInfoPtrTy,
+ bool hasNullCheck) {
+ Address thisPtr = cgf.emitLValue(e).getAddress();
+ QualType srcType = e->getType();
+
+ // C++ [class.cdtor]p4:
+ // If the operand of typeid refers to the object under construction or
+ // destruction and the static type of the operand is neither the
constructor
+ // or destructor’s class nor one of its bases, the behavior is undefined.
+ assert(!cir::MissingFeatures::sanitizers());
+
+ if (hasNullCheck && cgf.cgm.getCXXABI().shouldTypeidBeNullChecked(srcType)) {
+ mlir::Value isThisNull =
+ cgf.getBuilder().createPtrIsNull(thisPtr.getPointer());
+ // We don't really care about the value, we just want to make sure the
+ // 'true' side calls bad-type-id.
+ auto ifOp = cir::IfOp::create(
+ cgf.getBuilder(), cgf.getLoc(e->getSourceRange()), isThisNull,
+ /*withElseRegion=*/false, [&](mlir::OpBuilder &, mlir::Location loc) {
+ cgf.cgm.getCXXABI().emitBadTypeidCall(cgf, loc);
+ });
+ cgf.getBuilder().setInsertionPointAfter(ifOp);
----------------
erichkeane wrote:
Oh, right, I think this is left over from a previous problem I was having (I
was making a copy of builder above, and it was resulting in the insertion point
not changing.
https://github.com/llvm/llvm-project/pull/184449
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits