[llvm-branch-commits] [clang] [analyzer][NFC] Index parameter lookups by argument position (PR #221977)

Donát Nagy via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Sep 15 04:50:02 PDT 2026


================
@@ -63,23 +80,27 @@ void setBitsAccordingToFunctionAttributes(const CallType &Call,
       // 'nonnull' attribute's parameters are 1-based and should be adjusted to
       // match actual AST parameter/argument indices.
       unsigned IdxAST = Idx.getASTIndex();
-      if (IdxAST >= AttrNonNull.size())
+      if (IdxAST < Offset)
+        continue;
+      const unsigned IdxArg = IdxAST - Offset;
----------------
NagyDonat wrote:

> I would actually name it DeclParamIdx.

If that is the correct choice – thanks for correcting me. I just guessed that `ASTIdx` looks like `ASTArgIdx` and didn't verify in the source what kind of index is it in fact :sweat_smile: 

Please also drop a comment like "getAstIndex() returns the index of the parameter in the function declaration." next to the statement `unsigend DeclParamIdx = Idx.getASTIndex();` to save the reader the need to jump to its definition.

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


More information about the llvm-branch-commits mailing list