[clang] [PAC] Add support for __ptrauth type qualifier (PR #100830)
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 24 13:13:17 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);
----------------
ahatanak wrote:
The prototype is only needed to build the attribute list for the call (see the call to `getCalleeFunctionProtoType` in `CodeGenModule::ConstructAttributeList`), so it's fine to pass null to `CGCalleeInfo`'s constructor here.
Note that there's an existing line passing null to the constructor of `CGCalleeInfo` near the end of `CodeGenFunction::EmitCallee`.
https://github.com/llvm/llvm-project/pull/100830
More information about the cfe-commits
mailing list