[clang] [CIR][ABI] Add restrict, nonnull, and ReturnsNonNull attributes (PR #188281)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 15 11:07:47 PDT 2026
================
@@ -668,8 +672,20 @@ void CIRGenModule::constructFunctionArgumentAttributes(
// that seems risky at the moment. At one point we should evaluate if at least
// dereferenceable, nonnull, and align can be combined.
const cir::CIRDataLayout &layout = getDataLayout();
- for (const auto &[argAttrList, argCanType] :
- llvm::zip_equal(argAttrs, info.arguments())) {
+ const auto *fd = dyn_cast_or_null<FunctionDecl>(targetDecl);
+
+ // Build a parallel vector of ParmVarDecls aligned with argAttrs.
+ // Instance methods have a leading 'this' slot with no ParmVarDecl.
+ SmallVector<const ParmVarDecl *> parmDecls(argAttrs.size(), nullptr);
+ if (fd) {
----------------
erichkeane wrote:
Don't use a loop for this, you should be able to use the range- initializer + a `insert` a nullptr at the front.
Second, this is problematic, as it does a `zip_equal` below. IF this ends up being empty or lesser than the list of `arguments` (such as if `!fd`) it makes the read on 717 UB.
https://github.com/llvm/llvm-project/pull/188281
More information about the cfe-commits
mailing list