[clang] [clang] Fix crash in code with StmtExpr and atomic char load in Expr::EvaluateAsRValue. (PR #106751)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 30 20:46:35 PDT 2024


tbaederr wrote:

Of course not!

The reason that `AtomicToNonAtomic` is handled but `NonAtomicToAtomic` isn't, is that this is in `IntExprEvaluator`, meaning the result must be a (non-atomic) integer. If it was atomic, it'd be in `AtomicExprEvaluator`.

This AST for the LHS of the binary operator:
```
BinaryOperator 0x521000074f38 'int' '+'
|-ImplicitCastExpr 0x521000074f18 'int' <IntegralCast>
| `-StmtExpr 0x521000074ec8 'atomic_char':'_Atomic(char)'
```

looks wrong. The `StmtExpr` is of atomic type but gets cast to an integer without a `AtomicToNonAtomic` cast. Is that cast missing?




https://github.com/llvm/llvm-project/pull/106751


More information about the cfe-commits mailing list