================ @@ -5349,6 +5350,40 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, return RValue::get(Result); } + case Builtin::BI__builtin_virtual_member_address: { + Address This = EmitLValue(E->getArg(0)).getAddress(); + APValue ConstMemFun; + E->getArg(1)->isCXX11ConstantExpr(getContext(), &ConstMemFun, nullptr); + const CXXMethodDecl *CXXMethod = + cast<CXXMethodDecl>(ConstMemFun.getMemberPointerDecl()); + const CGFunctionInfo &FInfo = + CGM.getTypes().arrangeCXXMethodDeclaration(CXXMethod); + llvm::FunctionType *Ty = CGM.getTypes().GetFunctionType(FInfo); + CGCallee VCallee = CGM.getCXXABI().getVirtualFunctionPointer( + *this, CXXMethod, This, Ty, E->getBeginLoc()); + llvm::Value *Callee = VCallee.getFunctionPointer(); + if (const CGPointerAuthInfo &Schema = VCallee.getPointerAuthInfo()) + Callee = EmitPointerAuthAuth(Schema, Callee); + return RValue::get(Callee); + } + + case Builtin::BI__builtin_get_vtable_pointer: { + const Expr *Target = E->getArg(0); + QualType TargetType = Target->getType(); + QualType RecordType = TargetType; + if (RecordType->isPointerOrReferenceType()) + RecordType = RecordType->getPointeeType(); + const CXXRecordDecl *Decl = RecordType->getAsCXXRecordDecl(); + assert(Decl); ---------------- ojhunt wrote:
Different authors over time, I'll unify on not asserting as null deref is the downstream outcome. https://github.com/llvm/llvm-project/pull/135469 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits