@@ -1908,7 +1908,23 @@ class Sema final : public SemaBase {
19081908 /// '\#pragma clang attribute push' directives to the given declaration.
19091909 void AddPragmaAttributes(Scope *S, Decl *D);
19101910
1911- void PrintPragmaAttributeInstantiationPoint();
1911+ using InstantiationContextDiagFuncRef =
1912+ llvm::function_ref<void(SourceLocation, PartialDiagnostic)>;
1913+ auto getDefaultDiagFunc() {
1914+ return [this](SourceLocation Loc, PartialDiagnostic PD) {
1915+ // This bypasses a lot of the filters in the diag engine, as it's
1916+ // to be used to attach notes to diagnostics which have already
1917+ // been filtered through.
1918+ DiagnosticBuilder Builder(Diags.Report(Loc, PD.getDiagID()));
1919+ PD.Emit(Builder);
1920+ };
1921+ }
1922+
1923+ void PrintPragmaAttributeInstantiationPoint(
1924+ InstantiationContextDiagFuncRef DiagFunc);
1925+ void PrintPragmaAttributeInstantiationPoint() {
1926+ PrintPragmaAttributeInstantiationPoint(getDefaultDiagFunc());
1927+ }
19121928
19131929 void DiagnoseUnterminatedPragmaAttribute();
19141930
@@ -13263,18 +13279,22 @@ class Sema final : public SemaBase {
1326313279 void pushCodeSynthesisContext(CodeSynthesisContext Ctx);
1326413280 void popCodeSynthesisContext();
1326513281
13266- void PrintContextStack() {
13282+ void PrintContextStack(InstantiationContextDiagFuncRef DiagFunc ) {
1326713283 if (!CodeSynthesisContexts.empty() &&
1326813284 CodeSynthesisContexts.size() != LastEmittedCodeSynthesisContextDepth) {
13269- PrintInstantiationStack();
13285+ PrintInstantiationStack(DiagFunc );
1327013286 LastEmittedCodeSynthesisContextDepth = CodeSynthesisContexts.size();
1327113287 }
1327213288 if (PragmaAttributeCurrentTargetDecl)
13273- PrintPragmaAttributeInstantiationPoint();
13289+ PrintPragmaAttributeInstantiationPoint(DiagFunc );
1327413290 }
13291+ void PrintContextStack() { PrintContextStack(getDefaultDiagFunc()); }
1327513292 /// Prints the current instantiation stack through a series of
1327613293 /// notes.
13277- void PrintInstantiationStack();
13294+ void PrintInstantiationStack(InstantiationContextDiagFuncRef DiagFunc);
13295+ void PrintInstantiationStack() {
13296+ PrintInstantiationStack(getDefaultDiagFunc());
13297+ }
1327813298
1327913299 /// Determines whether we are currently in a context where
1328013300 /// template argument substitution failures are not considered
0 commit comments