[clang] [Clang] Clarify diagnostic notes for implicitly generated deduction guides (PR #96084)

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 21 00:56:23 PDT 2024


================
@@ -12114,6 +12115,35 @@ static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand,
     return;
   }
 
+  // If this is an implicit deduction guide against an implicitly defined
+  // constructor, add a note for it. Neither these deduction guides nor their
+  // corresponding constructors are explicitly spelled in the source code,
+  // and simply producing a deduction failure note around the heading of the
+  // enclosing RecordDecl would be confusing.
+  //
+  // We prefer adding such notes at the end of the last deduction failure
+  // reason because duplicate code snippets appearing in the diagnostic
+  // would likely become noisy.
+  auto _ = llvm::make_scope_exit([&] {
+    auto *DG = dyn_cast<CXXDeductionGuideDecl>(Fn);
+    if (!DG || !DG->isImplicit() || DG->getCorrespondingConstructor())
----------------
hokein wrote:

(I assume we always print using-alias deduction guides)

Note that checking the implicit guides is not sufficient for using-alias deduction guides. Those synthesized from the explicitly written deduction guide will retain the explicit bit (to ensure correct function overload resolution).


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


More information about the cfe-commits mailing list