[clang] [Clang] Make __builtin_assume_dereferenceable constexpr (PR #169869)

NagaChaitanya Vellanki via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 16 08:20:36 PST 2025


================
@@ -20055,6 +20055,46 @@ class VoidExprEvaluator
       // The argument is not evaluated!
       return true;
 
+    case Builtin::BI__builtin_assume_dereferenceable: {
+      assert(E->getType()->isVoidType());
+      assert(E->getNumArgs() == 2);
+
+      APSInt ReqSizeVal;
+      if (!::EvaluateInteger(E->getArg(1), ReqSizeVal, Info))
+        return false;
+      if (ReqSizeVal.isZero())
+        return true;
+
+      LValue Pointer;
+      if (!EvaluatePointer(E->getArg(0), Pointer, Info)) {
+        if (EvaluateBuiltinConstantP(Info, E->getArg(0)))
----------------
chaitanyav wrote:

the doc says "The arguments to this function provide a start pointer P and a size S. S must be at least 1 and a constant."
https://clang.llvm.org/docs/LanguageExtensions.html#builtin-assume-dereferenceable

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


More information about the cfe-commits mailing list