[clang] [clang] CTAD alias: Respecte explicit deduction guides defined after the first use of the alias template. (PR #125478)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 3 05:31:01 PST 2025
================
@@ -740,6 +740,24 @@ bool hasDeclaredDeductionGuides(DeclarationName Name, DeclContext *DC) {
return false;
}
+// Returns all source deduction guides associated with the declared
+// deduction guides that have the specified deduction guide name.
+llvm::DenseSet<const NamedDecl *> getSourceDeductionGuides(DeclarationName Name,
+ DeclContext *DC) {
+ assert(Name.getNameKind() ==
+ DeclarationName::NameKind::CXXDeductionGuideName &&
+ "name must be a deduction guide name");
+ llvm::DenseSet<const NamedDecl *> Result;
+ for (auto *D : DC->lookup(Name)) {
+ if (const auto *FTD = dyn_cast<FunctionTemplateDecl>(D))
+ D = FTD->getTemplatedDecl();
+
+ if (const auto *GD = dyn_cast<CXXDeductionGuideDecl>(D))
+ Result.insert(GD->getSourceDeductionGuide());
----------------
hokein wrote:
Added an assertion -- this cannot be nullptr in theory. The function is only called for the alias templates, if a deduction guide exists for a type alias, then it must be generated from a source deduction guide by definition.
https://github.com/llvm/llvm-project/pull/125478
More information about the cfe-commits
mailing list