[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)

Hubert Tong via llvm-commits llvm-commits at lists.llvm.org
Sun May 19 15:57:45 PDT 2024


================
@@ -3452,9 +3452,10 @@ def Fmod : FPMathTemplate, LibBuiltin<"math.h"> {
 
 def Frexp : FPMathTemplate, LibBuiltin<"math.h"> {
   let Spellings = ["frexp"];
-  let Attributes = [NoThrow];
+  let Attributes = [NoThrow, Constexpr];
----------------
hubert-reinterpretcast wrote:

> IMO we'd probably want to introduce the concept of "constexpr since C++xy".

@philnik777, are you envisioning something where `LangOptions` are passed into `Builtin::Context::isConstantEvaluated`?
https://github.com/llvm/llvm-project/blob/fb2c6597e39e9e1a775525ea0236b2f89e46acff/clang/include/clang/Basic/Builtins.h#L279

I think the existing `Constexpr`/"`E`" attribute can be left alone for use in "always `constexpr`" cases.

For the selectively-`constexpr` cases, `LibBuiltin` in `clang/include/clang/Basic/BuiltinsBase.td` should have `OnlyBuiltinPrefixedAliasIsConstexpr` renamed to `BuiltinPrefixedAliasIsConstexpr`. Then adding a new string property for `UnprefixedOnlyConstexprSince` makes sense to me. It can be encoded into `Builtin::Info` (and I think using the `LangFeatures` enumeration from `"clang/Basic/LangStandard.h"` is not terribly wrong).


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


More information about the llvm-commits mailing list