================ @@ -5560,6 +5560,25 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc, Init, InitializationContext->Context); } +static FieldDecl *FindFieldDeclInstantiationPattern(const ASTContext &Ctx, + FieldDecl *Field) { + if (FieldDecl *Pattern = Ctx.getInstantiatedFromUnnamedFieldDecl(Field)) + return Pattern; + auto *ParentRD = cast<CXXRecordDecl>(Field->getParent()); + CXXRecordDecl *ClassPattern = ParentRD->getTemplateInstantiationPattern(); + DeclContext::lookup_result Lookup = + ClassPattern->lookup(Field->getDeclName()); + auto Rng = llvm::make_filter_range(Lookup, [] (auto && L) { + return isa<FieldDecl>(*L); + }); + // FIXME: this breaks clang/test/Modules/pr28812.cpp + // assert(std::distance(Rng.begin(), Rng.end()) <= 1 + // && "Duplicated instantiation pattern for field decl"); + if(Rng.empty()) ---------------- erichkeane wrote:
woops, I meant 'below'. Basically, just move 5577 to above 5574. Sorry about that :/ Basically, doing the `std::distance` check (when we re-enable it) before checking for `empty` seems silly. https://github.com/llvm/llvm-project/pull/114196 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits