[all-commits] [llvm/llvm-project] f933bb: [TableGen] Use guarded assert in constexpr functio...
Krzysztof Parzyszek via All-commits
all-commits at lists.llvm.org
Wed Apr 29 08:36:28 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f933bbf694b82845d3d25cc4cf77b0486bff1191
https://github.com/llvm/llvm-project/commit/f933bbf694b82845d3d25cc4cf77b0486bff1191
Author: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: 2026-04-29 (Wed, 29 Apr 2026)
Changed paths:
M llvm/test/TableGen/directive1.td
M llvm/test/TableGen/directive2.td
M llvm/utils/TableGen/Basic/DirectiveEmitter.cpp
Log Message:
-----------
[TableGen] Use guarded assert in constexpr functions (#194728)
The constexpr functions in question take a scoped enum as an argument
and a switch statement returns a value for each value of the enum. These
are all legal statements in a constexpr function in C++14.
Under constexpr rules, the evaluation of a constexpr function cannot
lead to an evaluation of any prohibited forms of expressions. An
evaluation of the functions being discussed with a valid argument will
terminate at the switch, and an code that follows will not be evaluated.
Using "llvm_unreachable" after the switch should be ok as long as the
expansion of the llvm_unreachable macro does not contain any statements
not allowed to appear in a constexpr function. At the same time, GCC
before v9 did not tolerate any unguarded calls to non-constexpr
functions after the switch.
To avoid using "llvm_unreachable", which can have multiple expansions,
use an assert with an explicit condition that the underlying value of
the argument lies between the minimum and maximum values of the enum.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list