[clang] [clang][PAC] Add __builtin_get_vtable_pointer (PR #139790)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 2 16:31:35 PDT 2025
================
@@ -1825,6 +1825,37 @@ static ExprResult PointerAuthStringDiscriminator(Sema &S, CallExpr *Call) {
return Call;
}
+static ExprResult GetVTablePointer(Sema &S, CallExpr *Call) {
+ if (S.checkArgCount(Call, 1))
+ return ExprError();
+ ExprResult ThisArg = S.DefaultFunctionArrayLvalueConversion(Call->getArg(0));
+ if (ThisArg.isInvalid())
+ return ExprError();
+ Call->setArg(0, ThisArg.get());
+ const Expr *Subject = Call->getArg(0);
+ QualType SubjectType = Subject->getType();
+ const CXXRecordDecl *SubjectRecord = SubjectType->getPointeeCXXRecordDecl();
+ if (!SubjectType->isPointerType() || !SubjectRecord) {
+ S.Diag(Subject->getBeginLoc(), diag::err_get_vtable_pointer_incorrect_type)
+ << 0 << SubjectType;
----------------
ojhunt wrote:
or we could make every diag encode the type of the diag as a function type, and have things fail at compile time when possible. This would be super great as it would provide a great stress test for clangs template code :D :D :D
https://github.com/llvm/llvm-project/pull/139790
More information about the cfe-commits
mailing list