NagyDonat wrote:
:thinking: I agree that it wouldn't be elegant to add
> ```
> + if (isa_and_nonnull<SymbolOverlyComplex>(lhs.getAsSymbol()) ||
> + isa_and_nonnull<SymbolOverlyComplex>(rhs.getAsSymbol()))
> + return UnknownVal();
> ```
because this way `SymbolOverlyComplex` would become an overcomplicated
intermediate step that always leads to `UnknownVal`.
However, as I think about this situation, I realized that it's completely
arbitrary that we're putting a complexity limit on the _result_ symbol -- we
might as well introduce a complexity threshold above which symbols cannot
_participate in calculations_:
```c++
if (lhs.getAsSymbol() && lhs.getAsSymbol()->complexity() > Threshold ||
lhs.getAsSymbol() && lhs.getAsSymbol()->complexity() > Threshold)
return UnknownVal();
```
This different sort of limitation still guarantees that we cannot build overly
complex symbols, but its implementation is significantly shorter (just three
early return statements for unary operator, binary operator and cast
evaluation).
:bulb: In fact, you can add the complexity values of the two operands to get a
heuristic which is practically equivalent to the complexity threshold that you
want, but doesn't pass around `UnknownVal`s in already complex code and doesn't
introduce a new symbol type.
https://github.com/llvm/llvm-project/pull/144327
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits