[clang] [clang][Sema] Handle alloc_align on all HasFunctionProto declarations (PR #210871)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 29 16:48:59 PDT 2026


================
@@ -77,6 +82,33 @@ inline const ParmVarDecl *getFunctionOrMethodParam(const Decl *D,
     return MD->getParamDecl(Idx);
   if (const auto *BD = dyn_cast<BlockDecl>(D))
     return BD->getParamDecl(Idx);
+
+  // Handle declarations that do not directly own parameters but have an
+  // underlying FunctionProtoType (e.g. function pointers).
+  const TypeSourceInfo *TSI = nullptr;
+  if (const auto *DD = dyn_cast<DeclaratorDecl>(D))
+    TSI = DD->getTypeSourceInfo();
+  else if (const auto *TD = dyn_cast<TypedefNameDecl>(D))
+    TSI = TD->getTypeSourceInfo();
+
+  if (!TSI)
+    return nullptr;
+
+  TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc();
+
+  if (auto PTL = TL.getAsAdjusted<PointerTypeLoc>())
+    TL = PTL.getPointeeLoc();
----------------
erichkeane wrote:

Since these are diving into pointees, is there a possibility that they are member-ptr-type-inside-ptr-type-inside-ref-type-loc or something? 

Also, do we have tests for all of these combos? 

https://github.com/llvm/llvm-project/pull/210871


More information about the cfe-commits mailing list