================ @@ -5560,6 +5560,27 @@ 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()); + FieldDecl *Found = nullptr; + for (auto *L : Lookup) { + if (FieldDecl *Pattern = dyn_cast<FieldDecl>(L)) { + assert(!Found && "Duplicated instantiation pattern for field decl"); ---------------- erichkeane wrote:
This is probably better as a `llvm::make_filter_range`, or a llvm::find_if, either with `llvm::IsaPred<FieldDecl>`. Also makes your "ensure we only find one" a little less odd looking, since you could do something like: `assert(++Itr == range.end())` kinda thing. 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