[clang] [analyzer] Handle [[assume(cond)]] as __builtin_assume(cond) (PR #116462)
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 29 00:45:25 PST 2024
steakhal wrote:
I wanted to come back with another example:
```c++
int ternary_in_assume(int a, int b) {
[[assume(a > 10 ? b == 4 : b == 10)]];
if (a > 20)
return b + 100; // expecting 104
if (a > 10)
return b + 200; // expecting 204
return b + 300; // expecting 310
}
```
Actually, neither gcc, clang, msvc, or icc optimizes the return paths to constants - even though I think they would be allowed to. https://compiler-explorer.com/z/1ajvcvG9h
I'd need to think about of the implications for us though. I think it should be safe to eval these subexpressions and do state splits if and only if none of those expressions have sideeffects. In that case, they wouldn't be emitted into the CFG, so they shouldn't be a problem.
https://github.com/llvm/llvm-project/pull/116462
More information about the cfe-commits
mailing list