| 1780 | //----------------------------------------------------------------------------- |
| 1781 | |
| 1782 | void CodeGenerator::InsertTemplateParameters(const TemplateParameterList& list, |
| 1783 | const TemplateParamsOnly templateParamsOnly) |
| 1784 | { |
| 1785 | const bool full{TemplateParamsOnly::No == templateParamsOnly}; |
| 1786 | |
| 1787 | if(full) { |
| 1788 | for(const auto* param : list) { |
| 1789 | if(const auto* nonTmplParam = dyn_cast_or_null<NonTypeTemplateParmDecl>(param); |
| 1790 | nonTmplParam and nonTmplParam->hasDefaultArgument()) { |
| 1791 | if(auto val = |
| 1792 | EvaluateNTTPAsConstantExpr(nonTmplParam->getDefaultArgument().getArgument().getAsExpr())) { |
| 1793 | auto* init = GetGlobalAST().getTemplateParamObjectDecl(val->first, val->second); |
| 1794 | |
| 1795 | InsertTemplateArgsObjectParam(*init); |
| 1796 | } |
| 1797 | } |
| 1798 | } |
| 1799 | |
| 1800 | mOutputFormatHelper.Append(kwTemplate); |
| 1801 | } |
| 1802 | |
| 1803 | mOutputFormatHelper.Append("<"sv); |
| 1804 | |
| 1805 | for(OnceFalse needsComma{}; const auto* param : list) { |
| 1806 | mOutputFormatHelper.AppendComma(needsComma); |
| 1807 | |
| 1808 | const auto& typeName = GetName(*param); |
| 1809 | |
| 1810 | if(const auto* tt = dyn_cast_or_null<TemplateTypeParmDecl>(param)) { |
| 1811 | if(full) { |
| 1812 | if(tt->wasDeclaredWithTypename()) { |
| 1813 | mOutputFormatHelper.Append(kwTypeNameSpace); |
| 1814 | } else if(not tt->hasTypeConstraint()) { |
| 1815 | mOutputFormatHelper.Append(kwClassSpace); |
| 1816 | } |
| 1817 | |
| 1818 | mOutputFormatHelper.Append(EllipsisSpace(tt->isParameterPack())); |
| 1819 | } |
| 1820 | |
| 1821 | if(0 == typeName.size() or tt->isImplicit() /* fixes class container:auto*/) { |
| 1822 | AppendTemplateTypeParamName(mOutputFormatHelper, tt, not full); |
| 1823 | |
| 1824 | } else { |
| 1825 | if(auto typeConstraint = GetTypeConstraintAsString(tt->getTypeConstraint()); |
| 1826 | not typeConstraint.empty()) { |
| 1827 | mOutputFormatHelper.Append(std::move(typeConstraint), " "sv); |
| 1828 | } |
| 1829 | |
| 1830 | mOutputFormatHelper.Append(typeName); |
| 1831 | } |
| 1832 | |
| 1833 | mOutputFormatHelper.Append(EllipsisSpace(not full and tt->isParameterPack())); |
| 1834 | |
| 1835 | if(tt->hasDefaultArgument() and not tt->defaultArgumentWasInherited()) { |
| 1836 | const auto& defaultArg = tt->getDefaultArgument(); |
| 1837 | |
| 1838 | if(const auto decltypeType = dyn_cast_or_null<DecltypeType>(defaultArg.getArgument().getAsType())) { |
| 1839 | mOutputFormatHelper.Append(hlpAssing); |
no test coverage detected