[clang] [PAC] Add support for __ptrauth type qualifier (PR #100830)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 20 08:03:24 PST 2025
================
@@ -5708,6 +5732,27 @@ CGCallee CodeGenFunction::EmitCallee(const Expr *E) {
return EmitCallee(ICE->getSubExpr());
}
+ // Try to remember the original __ptrauth qualifier for loads of
+ // function pointers.
+ if (ICE->getCastKind() == CK_LValueToRValue) {
+ const auto *SubExpr = ICE->getSubExpr();
+ if (const auto *PtrType = SubExpr->getType()->getAs<PointerType>()) {
+ auto Result = EmitOrigPointerRValue(E);
+
+ QualType FunctionType = PtrType->getPointeeType();
+ assert(FunctionType->isFunctionType());
+
+ GlobalDecl GD;
+ if (const auto *VD =
+ dyn_cast_or_null<VarDecl>(E->getReferencedDeclOfCallee())) {
+ GD = GlobalDecl(VD);
+ }
+ CGCalleeInfo CalleeInfo(FunctionType->getAs<FunctionProtoType>(), GD);
----------------
AaronBallman wrote:
I don't see any code which prohibits use on K&R C functions, so this `getAs` can return null. Should we prohibit such a use in Sema or fix the use here and add test coverage?
https://github.com/llvm/llvm-project/pull/100830
More information about the cfe-commits
mailing list