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

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 21 06:18:12 PDT 2026


================
@@ -1509,16 +1509,15 @@ void Sema::AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI,
   }
 
   ParamIdx Idx;
-  const auto *FuncDecl = cast<FunctionDecl>(D);
-  if (!checkFunctionOrMethodParameterIndex(FuncDecl, CI,
+  if (!checkFunctionOrMethodParameterIndex(D, CI,
                                            /*AttrArgNum=*/1, ParamExpr, Idx))
     return;
 
   QualType Ty = getFunctionOrMethodParamType(D, Idx.getASTIndex());
   if (!Ty->isDependentType() && !Ty->isIntegralType(Context) &&
       !Ty->isAlignValT()) {
     Diag(ParamExpr->getBeginLoc(), diag::err_attribute_integers_only)
-        << CI << FuncDecl->getParamDecl(Idx.getASTIndex())->getSourceRange();
+        << CI << getFunctionOrMethodParamRange(D, Idx.getASTIndex());
----------------
erichkeane wrote:

I confirmed that this is the only thing in this function that is somewhat problematic.  This will result in an empty range for the param. BUT I don't think we can/want to do any better?  @AaronBallman WDYT? 

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


More information about the cfe-commits mailing list