diff options
author | Matheus Izvekov <mizvekov@gmail.com> | 2024-05-21 20:27:50 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-21 20:27:50 -0300 |
commit | e42b799bb28815431f2c5a95f7e13fde3f1b36a1 (patch) | |
tree | bb6d81d96bbac27b9455b5f1dd70fed08b15911a /clang/lib/ExtractAPI/DeclarationFragments.cpp | |
parent | b90861498b5b5c06ba24a122b6987738560acf99 (diff) | |
download | llvm-e42b799bb28815431f2c5a95f7e13fde3f1b36a1.zip llvm-e42b799bb28815431f2c5a95f7e13fde3f1b36a1.tar.gz llvm-e42b799bb28815431f2c5a95f7e13fde3f1b36a1.tar.bz2 |
[clang] NFCI: use TemplateArgumentLoc for type-param DefaultArgument (#92854)
This is an enabler for a future patch.
This allows an type-parameter default argument to be set as an arbitrary
TemplateArgument, not just a type.
This allows template parameter packs to have default arguments in the
AST, even though the language proper doesn't support the syntax for it.
This will be used in a later patch which synthesizes template parameter
lists with arbitrary default arguments taken from template
specializations.
There are a few places we used SubsType, because we only had a type, now
we use SubstTemplateArgument.
SubstTemplateArgument was missing arguments for setting Instantiation
location and entity names.
Adding those is needed so we don't regress in diagnostics.
Diffstat (limited to 'clang/lib/ExtractAPI/DeclarationFragments.cpp')
-rw-r--r-- | clang/lib/ExtractAPI/DeclarationFragments.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp b/clang/lib/ExtractAPI/DeclarationFragments.cpp index 98b9343..d88e4e0 100644 --- a/clang/lib/ExtractAPI/DeclarationFragments.cpp +++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp @@ -999,11 +999,11 @@ DeclarationFragmentsBuilder::getFragmentsForTemplateParameters( DeclarationFragments::FragmentKind::GenericParameter); if (TemplateParam->hasDefaultArgument()) { - DeclarationFragments After; + const auto Default = TemplateParam->getDefaultArgument(); Fragments.append(" = ", DeclarationFragments::FragmentKind::Text) - .append(getFragmentsForType(TemplateParam->getDefaultArgument(), - TemplateParam->getASTContext(), After)); - Fragments.append(std::move(After)); + .append(getFragmentsForTemplateArguments( + {Default.getArgument()}, TemplateParam->getASTContext(), + {Default})); } } else if (const auto *NTP = dyn_cast<NonTypeTemplateParmDecl>(ParameterArray[i])) { |