[clang] [CIR] Implement 'typeid' operator lowering (PR #184449)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 4 11:58:28 PST 2026
================
@@ -1550,6 +1558,49 @@ mlir::Attribute CIRGenItaniumRTTIBuilder::buildTypeInfo(
return builder.getGlobalViewAttr(builder.getUInt8PtrTy(), gv);
}
+bool CIRGenItaniumCXXABI::shouldTypeidBeNullChecked(QualType srcTy) {
+ return true;
+}
+
+void CIRGenItaniumCXXABI::emitBadTypeidCall(CIRGenFunction &cgf,
+ mlir::Location loc) {
+ // void __cxa_bad_typeid();
+ cir::FuncType fnTy =
+ cgf.getBuilder().getFuncType({}, cgf.getBuilder().getVoidTy());
+ mlir::NamedAttrList attrs;
+ attrs.set(cir::CIRDialect::getNoReturnAttrName(),
+ mlir::UnitAttr::get(&cgf.cgm.getMLIRContext()));
+
+ cgf.emitRuntimeCall(
+ loc, cgf.cgm.createRuntimeFunction(fnTy, "__cxa_bad_typeid", attrs), {},
+ attrs);
+ cir::UnreachableOp::create(cgf.getBuilder(), loc);
+ cgf.getBuilder().clearInsertionPoint();
----------------
erichkeane wrote:
That... is an excellent question. I don't see why I did that at all.
https://github.com/llvm/llvm-project/pull/184449
More information about the cfe-commits
mailing list