[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 8 10:54:27 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;
+ if (IdxArg >= AttrNonNull.size())
continue;
- AttrNonNull.set(IdxAST);
+ AttrNonNull.set(IdxArg);
}
}
}
template <class CallType>
void setBitsAccordingToParameterAttributes(const CallType &Call,
llvm::SmallBitVector &AttrNonNull) {
+ unsigned ArgIdx = 0;
----------------
NagyDonat wrote:
Why is this an `ArgIdx` when it is incremented in a loop that iterates over `Call.parameters()`??
I feel that the old `ParameterIdx` is more natural – and if this is the "native" indexing kind of `CallEvent` and can index both arguments and parameters (this is my guess but I'm not sure), then choose a name like `ImplIdx` or `NativeIdx` that does not refer to either `Arg` or `Param`. (And consistently use the same name for all variables that hold this kind of index.)
https://github.com/llvm/llvm-project/pull/221977
More information about the llvm-branch-commits
mailing list