[clang] [Clang][RFC] Intrododuce a builtin to determine the structure binding size (PR #131515)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 17 11:28:58 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;
----------------
cor3ntin wrote:
Yup. I'm not sure we can do better here - It's ensure we have at least one diagnostics if we forget a case
https://github.com/llvm/llvm-project/pull/131515
More information about the cfe-commits
mailing list