@@ -42,8 +42,8 @@ namespace ranges = std::ranges;
4242// -----------------------------------------------------------------------------
4343namespace clang ::insights {
4444
45- #define BUILD_OPT_AND (name, param ) std::function name = [](param t) -> MyOptional<param>
46- #define BUILD_OPT_AND_O (name, param, ret ) std::function name = [](param t) -> MyOptional<ret>
45+ #define BUILD_OPT_AND (name, param ) std::function name = [](param t)-> MyOptional<param>
46+ #define BUILD_OPT_AND_O (name, param, ret ) std::function name = [](param t)-> MyOptional<ret>
4747
4848BUILD_OPT_AND (IsPointer, QualType)
4949{
@@ -1412,7 +1412,6 @@ void CodeGenerator::InsertArg(const VarDecl* stmt)
14121412 // }
14131413
14141414 } else {
1415- mProcessingVarDecl = false ;
14161415 BackupAndRestore _{mProcessingVarDecl , true };
14171416
14181417 if (MyOptional<const InitListExpr*> initList{dyn_cast_or_null<InitListExpr>(init)};
@@ -2398,18 +2397,20 @@ void CodeGenerator::InsertArg(const ImplicitCastExpr* stmt)
23982397 } else {
23992398 auto castName{GetCastName (castKind)};
24002399 const QualType castDestType{[&] {
2401- const auto type{stmt->getType ()};
2400+ auto type{stmt->getType ()};
2401+
2402+ // In case of a dependent type the canonical type doesn't know the parameters name.
2403+ if (not type->isDependentType ()) {
2404+ type = type.getCanonicalType ();
2405+ }
24022406
24032407 // In at least the case a structured bindings the compiler adds xvalue casts but the && is missing to
24042408 // make it valid C++.
24052409 if (VK_XValue == stmt->getValueKind ()) {
2406- return GetGlobalAST ().getRValueReferenceType (type.getCanonicalType ());
2407- } else if (type->isDependentType ()) { // In case of a dependent type the canonical type doesn't know the
2408- // parameters name.
2409- return type;
2410+ return GetGlobalAST ().getRValueReferenceType (type);
24102411 }
24112412
2412- return type. getCanonicalType () ;
2413+ return type;
24132414 }()};
24142415
24152416 FormatCast (castName, castDestType, subExpr, castKind);
@@ -3178,16 +3179,21 @@ void CodeGenerator::InsertArg(const TypeAliasDecl* stmt)
31783179 mOutputFormatHelper .Append (stream.str ());
31793180
31803181 InsertTemplateArgs (*templateSpecializationType);
3181- } else if (auto * dependentTemplateSpecializationType =
3182- underlyingType->getAs <DependentTemplateSpecializationType>()) {
31833182
3184- mOutputFormatHelper .Append (GetElaboratedTypeKeyword (dependentTemplateSpecializationType->getKeyword ()));
3183+ } else if (auto * depSpecType = underlyingType->getAs <DependentTemplateSpecializationType>()) {
3184+ mOutputFormatHelper .Append (GetElaboratedTypeKeyword (depSpecType->getKeyword ()));
31853185
3186- InsertNamespace (dependentTemplateSpecializationType->getQualifier ());
3186+ #if IS_CLANG_NEWER_THAN(20)
3187+ InsertNamespace (depSpecType->getDependentTemplateName ().getQualifier ());
31873188
3188- mOutputFormatHelper .Append (kwTemplateSpace, dependentTemplateSpecializationType->getIdentifier ()->getName ());
3189+ mOutputFormatHelper .Append (kwTemplateSpace, GetName (depSpecType->getDependentTemplateName ()));
3190+ #else
3191+ InsertNamespace (depSpecType->getQualifier ());
3192+
3193+ mOutputFormatHelper .Append (kwTemplateSpace, depSpecType->getIdentifier ()->getName ());
3194+ #endif
31893195
3190- InsertTemplateArgs (*dependentTemplateSpecializationType );
3196+ InsertTemplateArgs (*depSpecType );
31913197
31923198 } else {
31933199 mOutputFormatHelper .Append (GetName (underlyingType));
@@ -3802,6 +3808,11 @@ void CodeGenerator::InsertAttribute(const Attr& attr)
38023808 // skip this custom clang attribute
38033809 RETURN_IF (attr::NoInline == attr.getKind ());
38043810
3811+ #if IS_CLANG_NEWER_THAN(20)
3812+ // skip this custom clang attribute
3813+ RETURN_IF (attr::InferredNoReturn == attr.getKind ());
3814+ #endif
3815+
38053816 // Clang's printPretty misses the parameter pack ellipsis. Hence treat this special case here.
38063817 if (const auto * alignedAttr = dyn_cast_or_null<AlignedAttr>(&attr)) {
38073818 auto insert = [&](const QualType type, const TemplateTypeParmType* tmplTypeParam) {
@@ -4460,7 +4471,7 @@ void CodeGenerator::InsertArg(const CXXStdInitializerListExpr* stmt)
44604471 auto internalListName =
44614472 MakeLineColumnName (GetGlobalAST ().getSourceManager (), stmt->getBeginLoc (), BuildInternalVarName (" list" sv));
44624473
4463- ofm.Append (modifiers, GetTypeNameAsParameter (subExpr->getType (), internalListName));
4474+ ofm.Append (modifiers, GetTypeNameAsParameter (subExpr->getType (). getCanonicalType () , internalListName));
44644475 CodeGeneratorVariant codeGenerator{ofm};
44654476 codeGenerator->InsertArg (subExpr);
44664477 ofm.AppendSemiNewLine ();
@@ -4637,11 +4648,19 @@ void CodeGenerator::InsertTemplateArg(const TemplateArgument& arg)
46374648 if (const auto * tmplDecl = arg.getAsTemplateOrTemplatePattern ().getAsTemplateDecl ()) {
46384649 mOutputFormatHelper .Append (GetName (*tmplDecl, QualifiedName::Yes));
46394650
4651+ #if IS_CLANG_NEWER_THAN(20)
4652+ } else if (const auto * depName = arg.getAsTemplateOrTemplatePattern ().getAsDependentTemplateName ();
4653+ depName->getName ().getIdentifier ()) {
4654+ InsertNamespace (depName->getQualifier ());
4655+
4656+ mOutputFormatHelper .Append (kwTemplateSpace, GetName (*depName));
4657+ #else
46404658 } else if (const auto * depName = arg.getAsTemplateOrTemplatePattern ().getAsDependentTemplateName ();
46414659 depName->isIdentifier ()) {
46424660 InsertNamespace (depName->getQualifier ());
46434661
46444662 mOutputFormatHelper .Append (kwTemplateSpace, depName->getIdentifier ()->getName ());
4663+ #endif
46454664 } else {
46464665 ToDo (arg, mOutputFormatHelper );
46474666 }
@@ -4834,7 +4853,17 @@ void CodeGenerator::InsertConceptConstraint(const TemplateParameterList& tmplDec
48344853void CodeGenerator::InsertConceptConstraint (const FunctionDecl* tmplDecl)
48354854{
48364855 SmallVector<const Expr*, 5 > constraints{};
4856+
4857+ #if IS_CLANG_NEWER_THAN(20)
4858+ SmallVector<AssociatedConstraint, 5 > assocConstraints{};
4859+ tmplDecl->getAssociatedConstraints (assocConstraints);
4860+
4861+ for (auto & e : assocConstraints) {
4862+ constraints.push_back (e.ConstraintExpr );
4863+ }
4864+ #else
48374865 tmplDecl->getAssociatedConstraints (constraints);
4866+ #endif
48384867
48394868 InsertConceptConstraint (constraints, InsertInline::Yes);
48404869}
0 commit comments