[clang] [llvm] [TLI] Add support for reallocarray (PR #114818)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 8 05:47:13 PST 2024


================
@@ -577,6 +577,21 @@ bool llvm::inferNonMandatoryLibFuncAttrs(Function &F,
     Changed |= setDoesNotCapture(F, 0);
     Changed |= setArgNoUndef(F, 1);
     break;
+  case LibFunc_reallocarray:
+    Changed |= setAllocFamily(F, "malloc");
+    Changed |= setAllocKind(F, AllocFnKind::Realloc);
+    Changed |= setAllocatedPointerParam(F, 0);
+    Changed |= setAllocSize(F, 1, std::nullopt);
+    Changed |= setAllocSize(F, 2, std::nullopt);
----------------
nikic wrote:

That's not how it works, this needs to be:
```suggestion
    Changed |= setAllocSize(F, 1, 2);
```

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


More information about the cfe-commits mailing list