[PATCH] D55500: [Builtins] Implement __builtin_is_constant_evaluated for use in C++2a
Eric Fiselier via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 10 20:48:56 PST 2018
EricWF marked 2 inline comments as done.
EricWF added a comment.
Sorry for the delayed response. My email filters were incorrect.
================
Comment at: include/clang/Basic/Builtins.def:759
+// Random C++ builtins.
+LANGBUILTIN(__builtin_is_constant_evaluated, "b", "ncu", CXX_LANG)
+
----------------
bruno wrote:
> Name bikeshedding : perhaps the builtin name could be detached from the std:: name? Suggestion: `__builtin_in_constant_evaluation_context`
I'm not sure detaching it from the `std::` name is desirable. Most importantly it should match w/e GCC does/decides to do.
But if it is, we should name in deference to the standardese it implements. Specifically weither an expression or conversion is //manifestly constant-evaluated// [[expr.const](http://eel.is/c++draft/expr.const#11)]p11.
Therefore I proffer `__builtin_is_manifestly_constant_evaluated()` or `__builtin_is_being_manifestly_constant_evaluated()`.
================
Comment at: lib/AST/ExprConstant.cpp:8207
+ case Builtin::BI__builtin_is_constant_evaluated:
+ return Success(Info.InConstantContext, E);
----------------
bruno wrote:
> Do we need compat and extension warnings for the use of this builtin before c++2a? I assume people will play with the builtin before the library facility is there. OTOH, since this will be mainly exposed as a library thing, whatever check for c++ version is done at the library level should be enough?
No. We don't warn for any other builtin used to serve the standard library (`__is_constructible()`, `__builtin_addressof()`, etc)
The builtin is useful in all dialects, and I suspect users will frequently want to call it directly. If `__has_builtin(__builtin_is_constant_evaluated)` returns true, it should be safe to use.
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55500/new/
https://reviews.llvm.org/D55500
More information about the cfe-commits
mailing list