================
@@ -17097,6 +17097,15 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl 
*FD) {
       }
     }
 
+    SmallVector<int, 4> Indxs;
+    if (Context.BuiltinInfo.IsNonNull(BuiltinID, Indxs) &&
+        !FD->hasAttr<NonNullAttr>()) {
+      llvm::SmallVector<ParamIdx, 4> ParamIndxs;
+      for (int I : Indxs)
+        ParamIndxs.push_back(ParamIdx(I + 1, FD));
+      FD->addAttr(NonNullAttr::CreateImplicit(Context, ParamIndxs.data(),
+                                              ParamIndxs.size()));
----------------
Sirraide wrote:

I think it’d make more sense to create the `ParamIdx`’s in `isNonNull()` 
directly just to avoid any potential confusion about whether they’re supposed 
to be zero or one-based—also, I wonder if `NonNull` in TableGen shouldn’t just 
be one-based so we don’t have to remember to add `1` here.

https://github.com/llvm/llvm-project/pull/158626
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to