================ @@ -323,30 +324,101 @@ struct TemplateParameterListBuilder { S.Context, Builder.Record->getDeclContext(), SourceLocation(), SourceLocation(), /* TemplateDepth */ 0, Position, &S.Context.Idents.get(Name, tok::TokenKind::identifier), - /* Typename */ false, - /* ParameterPack */ false); + /* Typename */ true, + /* ParameterPack */ false, + /* HasTypeConstraint*/ false); if (!DefaultValue.isNull()) Decl->setDefaultArgument( S.Context, S.getTrivialTemplateArgumentLoc(DefaultValue, QualType(), SourceLocation())); - + Decl->setReferenced(); Params.emplace_back(Decl); return *this; } - BuiltinTypeDeclBuilder &finalizeTemplateArgs() { + ConceptSpecializationExpr *getConceptSpecializationExpr(Sema &S, + ConceptDecl *CD) { + ASTContext &context = S.getASTContext(); + SourceLocation loc = Builder.Record->getBeginLoc(); + DeclarationNameInfo DNI(CD->getDeclName(), loc); + NestedNameSpecifierLoc NNSLoc; + DeclContext *DC = Builder.Record->getDeclContext(); + TemplateArgumentListInfo TALI(loc, loc); + + // assume that the concept decl has just one template parameter + TemplateTypeParmDecl *ConceptTTPD = dyn_cast<TemplateTypeParmDecl>( + CD->getTemplateParameters()->getParam(0)); + + clang::TemplateTypeParmDecl *T = clang::TemplateTypeParmDecl::Create( + context, // AST context + context.getTranslationUnitDecl(), // DeclContext + SourceLocation(), SourceLocation(), + /*depth=*/0, // Depth in the template parameter list + /*position=*/0, // Position in the template parameter list + /*id=*/nullptr, // Identifier for 'T' + /*Typename=*/true, // Indicates this is a 'typename' or 'class' + /*ParameterPack=*/false, // Not a parameter pack + /*HasTypeConstraint=*/false // Not a parameter pack + ); + + T->setDeclContext(DC); + T->setReferenced(); + + clang::QualType ConceptTType = context.getTypeDeclType(ConceptTTPD); + + TemplateArgument ConceptTA = TemplateArgument(ConceptTType); + + std::vector<TemplateArgument> ConceptConvertedArgsVec = {ConceptTA}; + ArrayRef<TemplateArgument> ConceptConvertedArgs = ConceptConvertedArgsVec; + + clang::QualType CSETType = context.getTypeDeclType(T); + + TemplateArgument CSETA = TemplateArgument(CSETType); + + std::vector<TemplateArgument> CSEConvertedArgsVec = {CSETA}; + ArrayRef<TemplateArgument> CSEConvertedArgs = CSEConvertedArgsVec; + + ImplicitConceptSpecializationDecl *ImplicitCSEDecl = + ImplicitConceptSpecializationDecl::Create( + context, Builder.Record->getDeclContext(), loc, CSEConvertedArgs); + + const ConstraintSatisfaction CS(CD, ConceptConvertedArgs); ---------------- llvm-beanz wrote:
```suggestion clang::QualType CSETType = context.getTypeDeclType(T); TemplateArgument CSETA = TemplateArgument(CSETType); ImplicitConceptSpecializationDecl *ImplicitCSEDecl = ImplicitConceptSpecializationDecl::Create( context, Builder.Record->getDeclContext(), loc, {CSETA}); const ConstraintSatisfaction CS(CD, {ConceptTA}); ``` https://github.com/llvm/llvm-project/pull/112600 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits