[clang] [Clang] Add detailed notes explaining why is_aggregate evaluates to false (PR #152488)
Yanzuo Liu via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 9 01:01:18 PDT 2025
================
@@ -2595,6 +2596,105 @@ static void DiagnoseNonStandardLayoutReason(Sema &SemaRef, SourceLocation Loc,
SemaRef.Diag(D->getLocation(), diag::note_defined_here) << D;
}
+static void DiagnoseNonAggregateReason(Sema &SemaRef, SourceLocation Loc,
+ const CXXRecordDecl *D) {
+ for (const CXXConstructorDecl *Ctor : D->ctors()) {
+ if (Ctor->isUserProvided())
+ SemaRef.Diag(Loc, diag::note_unsatisfied_trait_reason)
+ << diag::TraitNotSatisfiedReason::UserDeclaredCtr;
+ if (Ctor->isInheritingConstructor())
+ SemaRef.Diag(Loc, diag::note_unsatisfied_trait_reason)
+ << diag::TraitNotSatisfiedReason::InheritedCtr;
+ }
+
+ bool HasInherited = false;
+ for (const Decl *Sub : D->decls()) {
+ if (auto *UD = dyn_cast<UsingDecl>(Sub)) {
+ for (auto I = UD->shadow_begin(), E = UD->shadow_end(); I != E; ++I) {
+ if (isa<ConstructorUsingShadowDecl>(*I)) {
+ HasInherited = true;
+ break;
+ }
+ }
+ if (HasInherited)
+ break;
+ }
+ if (isa<ConstructorUsingShadowDecl>(Sub)) {
+ HasInherited = true;
+ break;
+ }
+ }
----------------
zwuis wrote:
We can use `llvm::any_of` defined in `llvm/ADT/STLExtras.h`.
https://github.com/llvm/llvm-project/pull/152488
More information about the cfe-commits
mailing list