[clang] [Clang][RFC] Introduce a trait to determine the structure binding size (PR #131515)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 18 07:04:36 PDT 2025
================
@@ -1854,47 +1854,34 @@ bool MaterializeTemporaryExpr::isUsableInConstantExpressions(
TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind,
ArrayRef<TypeSourceInfo *> Args,
- SourceLocation RParenLoc, bool Value)
+ SourceLocation RParenLoc,
+ std::variant<bool, APValue> Value)
: Expr(TypeTraitExprClass, T, VK_PRValue, OK_Ordinary), Loc(Loc),
RParenLoc(RParenLoc) {
assert(Kind <= TT_Last && "invalid enum value!");
+
TypeTraitExprBits.Kind = Kind;
assert(static_cast<unsigned>(Kind) == TypeTraitExprBits.Kind &&
"TypeTraitExprBits.Kind overflow!");
- TypeTraitExprBits.IsBooleanTypeTrait = true;
- TypeTraitExprBits.Value = Value;
- TypeTraitExprBits.NumArgs = Args.size();
- assert(Args.size() == TypeTraitExprBits.NumArgs &&
- "TypeTraitExprBits.NumArgs overflow!");
- auto **ToArgs = getTrailingObjects<TypeSourceInfo *>();
- for (unsigned I = 0, N = Args.size(); I != N; ++I)
- ToArgs[I] = Args[I];
-
- setDependence(computeDependence(this));
-}
+ TypeTraitExprBits.IsBooleanTypeTrait = Value.index() == 0;
----------------
erichkeane wrote:
minor preference for `holds_alternative`.
https://github.com/llvm/llvm-project/pull/131515
More information about the cfe-commits
mailing list