================
@@ -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()));
----------------
bozicrHT wrote:

`ParamIdx` requires a `Decl` pointer as its second argument, which is only 
available in Sema, not in Builtins (which is included in the preamble). Because 
of that, constructing ParamIdx directly inside isNonNull() isn’t possible. 
That’s why I opted to create them later in Sema. We could consider a small 
refactor (e.g. a helper in Sema) if we want to make the one-based logic 
cleaner, but I think the current approach is the most practical.

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