[clang] [clang] Fix segmentation fault caused by stack overflow on deeply nested expressions (PR #111701)
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 10 07:18:12 PDT 2024
================
@@ -5817,7 +5817,10 @@ LValue CodeGenFunction::EmitHLSLArrayAssignLValue(const BinaryOperator *E) {
LValue CodeGenFunction::EmitCallExprLValue(const CallExpr *E,
llvm::CallBase **CallOrInvoke) {
- RValue RV = EmitCallExpr(E, ReturnValueSlot(), CallOrInvoke);
----------------
ilya-biryukov wrote:
Would it be better to wrap a more generic function? I'm thinking about `EmitLValue`
```cpp
LValue CodeGenFunction::EmitLValue(const Expr *E) {
LValue R;
R = runWithSufficientStackSpace([] { R = EmitLValueImpl(E); }, ...);
return R;
}
// The current function...
LValue CodeGenFunction::EmitLValueImpl(const Expr *E) {
ApplyDebugLocation DL(*this, E);
switch (E->getStmtClass()) {
...
}
```
That way we can cover a broader class of recursive expressions. I'm not sure the coverage is complete,
but should probably be quite good for a start.
(We could also add a few tests for deep expressions that don't involve calls).
https://github.com/llvm/llvm-project/pull/111701
More information about the cfe-commits
mailing list