[clang] [Clang][RFC] Intrododuce a builtin to determine the structure binding size (PR #131515)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 17 10:30:31 PDT 2025
================
@@ -5813,6 +5817,34 @@ static ExprResult CheckConvertibilityForTypeTraits(
return Result;
}
+static APValue EvaluateSizeTTypeTrait(Sema &S, TypeTrait Kind,
+ SourceLocation KWLoc,
+ ArrayRef<TypeSourceInfo *> Args,
+ SourceLocation RParenLoc,
+ bool IsDependent) {
+ if (IsDependent)
+ return APValue();
+
+ switch (Kind) {
+ case TypeTrait::UTT_StructuredBindingSize: {
+ QualType T = Args[0]->getType();
+ SourceRange ArgRange = Args[0]->getTypeLoc().getSourceRange();
+ std::optional<unsigned> Size =
+ S.GetDecompositionElementCount(T, ArgRange.getBegin());
+ if (!Size) {
+ S.Diag(KWLoc, diag::err_arg_is_not_destructurable) << T << ArgRange;
----------------
erichkeane wrote:
Ah, hmm... This would result in a complete-type diagnostic, followed by 'not destructurable'. I guess that is OK.
https://github.com/llvm/llvm-project/pull/131515
More information about the cfe-commits
mailing list