Index: clang/include/clang/Sema/Sema.h =================================================================== --- clang/include/clang/Sema/Sema.h +++ clang/include/clang/Sema/Sema.h @@ -1307,14 +1307,17 @@ void PrintStats() const; /// Warn that the stack is nearly exhausted. - void warnStackExhausted(SourceLocation Loc); + /// \param NoteDiagID Extra information of the user how to resolve the issue. + void warnStackExhausted(SourceLocation Loc, unsigned NoteDiagID = 0); /// Run some code with "sufficient" stack space. (Currently, at least 256K is /// guaranteed). Produces a warning if we're low on stack space and allocates /// more in that case. Use this in code that may recurse deeply (for example, /// in template instantiation) to avoid stack overflow. + /// \param NoteDiagID Extra information of the user how to resolve the issue. void runWithSufficientStackSpace(SourceLocation Loc, - llvm::function_ref Fn); + llvm::function_ref Fn, + unsigned NoteDiagID = 0); /// Helper class that creates diagnostics with optional /// template instantiation stacks. Index: clang/lib/Sema/Sema.cpp =================================================================== --- clang/lib/Sema/Sema.cpp +++ clang/lib/Sema/Sema.cpp @@ -386,17 +386,21 @@ SemaPPCallbackHandler->reset(); } -void Sema::warnStackExhausted(SourceLocation Loc) { +void Sema::warnStackExhausted(SourceLocation Loc, unsigned NoteDiagID) { // Only warn about this once. if (!WarnedStackExhausted) { Diag(Loc, diag::warn_stack_exhausted); + if (NoteDiagID) + Diag(Loc, NoteDiagID); WarnedStackExhausted = true; } } void Sema::runWithSufficientStackSpace(SourceLocation Loc, - llvm::function_ref Fn) { - clang::runWithSufficientStackSpace([&] { warnStackExhausted(Loc); }, Fn); + llvm::function_ref Fn, + unsigned NoteDiagID) { + clang::runWithSufficientStackSpace( + [&] { warnStackExhausted(Loc, NoteDiagID); }, Fn); } /// makeUnavailableInSystemHeader - There is an error in the current