-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[clang] Fix segmentation fault caused by stack overflow on deeply nested expressions #111701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
1a63281
0100615
d43be53
93e4a73
84996d6
da8b92c
50bec16
856e26d
6f5ef5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,7 @@ | |
| #include "clang/Basic/FileManager.h" | ||
| #include "clang/Basic/Module.h" | ||
| #include "clang/Basic/SourceManager.h" | ||
| #include "clang/Basic/Stack.h" | ||
| #include "clang/Basic/TargetInfo.h" | ||
| #include "clang/Basic/Version.h" | ||
| #include "clang/CodeGen/BackendUtil.h" | ||
|
|
@@ -1596,6 +1597,19 @@ void CodeGenModule::ErrorUnsupported(const Decl *D, const char *Type) { | |
| getDiags().Report(Context.getFullLoc(D->getLocation()), DiagID) << Msg; | ||
| } | ||
|
|
||
| void CodeGenModule::warnStackExhausted(SourceLocation Loc) { | ||
| // Only warn about this once. | ||
| if (!WarnedStackExhausted) { | ||
| getDiags().Report(Loc, diag::warn_stack_exhausted); | ||
| WarnedStackExhausted = true; | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a way to avoid the duplication with Sema here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking that as a follow up I will extract this small logic into a class which both Sema and CodeGen would own.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SGTM and also feels like something that we could do in a follow-up, even if the code here is duplicated for some short period of time. I suspect there's some wiring up to figure out for sharing this in the same class, so it'd be good to land this while that's still happening. |
||
|
|
||
| void CodeGenModule::runWithSufficientStackSpace(SourceLocation Loc, | ||
| llvm::function_ref<void()> Fn) { | ||
| clang::runWithSufficientStackSpace([&] { warnStackExhausted(Loc); }, Fn); | ||
| } | ||
|
|
||
| llvm::ConstantInt *CodeGenModule::getSize(CharUnits size) { | ||
| return llvm::ConstantInt::get(SizeTy, size.getQuantity()); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.