[clang] [clang] CTAD alias: Respecte explicit deduction guides defined after the first use of the alias template. (PR #125478)

via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 3 04:00:13 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());
----------------
cor3ntin wrote:

This can be null right? So we'd be inserting a bunch of nullptr into the map which is harmless but also not useful

https://github.com/llvm/llvm-project/pull/125478


More information about the cfe-commits mailing list