[PATCH] D69478: [Sema] Allow warnStackExhausted to show more info
Mark de Wever via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 27 09:14:32 PDT 2019
Mordante created this revision.
Mordante added reviewers: rnk, rsmith, aaron.ballman.
Mordante added a project: clang.
This allows the caller of the function to add a note about how to fix the stack exhaustion. This can be useful to aid the user. For example it can be used to show a help message for https://bugs.llvm.org/show_bug.cgi?id=14030
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D69478
Files:
clang/include/clang/Sema/Sema.h
clang/lib/Sema/Sema.cpp
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<void()> Fn) {
- clang::runWithSufficientStackSpace([&] { warnStackExhausted(Loc); }, Fn);
+ llvm::function_ref<void()> Fn,
+ unsigned NoteDiagID) {
+ clang::runWithSufficientStackSpace(
+ [&] { warnStackExhausted(Loc, NoteDiagID); }, Fn);
}
/// makeUnavailableInSystemHeader - There is an error in the current
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<void()> Fn);
+ llvm::function_ref<void()> Fn,
+ unsigned NoteDiagID = 0);
/// Helper class that creates diagnostics with optional
/// template instantiation stacks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69478.226576.patch
Type: text/x-patch
Size: 2284 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191027/8a2afed1/attachment.bin>
More information about the cfe-commits
mailing list