[clang] [clang] Add missing readonly/readnone annotations (PR #158424)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 17 13:52:46 PDT 2025


================
@@ -3011,6 +3016,37 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
   }
   assert(ArgNo == FI.arg_size());
 
+  ArgNo = 0;
+  if (AddedPotentialArgAccess && MemAttrForPtrArgs) {
+    llvm::SmallSet<unsigned, 8> ArgsToSkip;
+    if (IRFunctionArgs.hasSRetArg()) {
+      ArgsToSkip.insert(IRFunctionArgs.getSRetArgNo());
+    }
+    if (IRFunctionArgs.hasInallocaArg()) {
+      ArgsToSkip.insert(IRFunctionArgs.getInallocaArgNo());
+    }
+
+    for (CGFunctionInfo::const_arg_iterator I = FI.arg_begin(),
+                                            E = FI.arg_end();
+         I != E; ++I, ++ArgNo) {
+      if (I->info.getKind() == ABIArgInfo::Indirect) {
----------------
efriedma-quic wrote:

Looking through the kinds in clang/include/clang/CodeGen/CGFunctionInfo.h, I'm not sure Indirect is the only thing that needs to be handled specially.

I'd prefer to explicitly handle the cases you know are safe (Direct, Expand, CoerceAndExpand).

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


More information about the cfe-commits mailing list