================ @@ -1909,7 +1909,19 @@ class Sema final : public SemaBase { /// '\#pragma clang attribute push' directives to the given declaration. void AddPragmaAttributes(Scope *S, Decl *D); - void PrintPragmaAttributeInstantiationPoint(); + using DiagFuncRef = + llvm::function_ref<void(SourceLocation, PartialDiagnostic)>; + auto getDefaultDiagFunc() { + return [this](SourceLocation Loc, PartialDiagnostic PD) { ---------------- mizvekov wrote:
I tried that, but I didn't like the result. most of the uses are lines like: ``` DiagFunc(Active->PointOfInstantiation, PDiag(diag::note_template_default_arg_checking) << getTemplateArgumentBindingsText(TemplateParams, Active->TemplateArgs, Active->NumTemplateArgs) << Active->InstantiationRange); ``` Which become: ``` DiagFunc(PartialDiagnosticAt(Active->PointOfInstantiation, PDiag(diag::note_template_default_arg_checking) << getTemplateArgumentBindingsText(TemplateParams, Active->TemplateArgs, Active->NumTemplateArgs) << Active->InstantiationRange)); ``` You can swap the explicit construction with braces, but that still looks a bit off. On the receiving side, none of the users take a PartialDiagnosticAt anyway, so you have to decompose it. So right now this is just adding friction to the API. If we really wanted to do this, I think we would have to provide equivalents to all existing APIs which take a partial diagnostic, including the '<<' operator, then this would look nice, but it's a bigger cleanup which is a bit unrelated to this patch. Ie if we had: ```C++ DiagFunc(PDiagAt(Active->PointOfInstantiation, diag::note_template_default_arg_checking) << getTemplateArgumentBindingsText(TemplateParams, Active->TemplateArgs, Active->NumTemplateArgs) << Active->InstantiationRange)); ``` And: ```C++ return [this](PartialDiagnosticAt PDA) { DiagnosticBuilder Builder(Diags.Report(PDA)); PDA.Emit(Builder); } ``` https://github.com/llvm/llvm-project/pull/125453 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits