[clang] [StaticAnalyzer] early return if sym is concrete on assuming (PR #115579)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 11 03:34:36 PST 2024


================
@@ -23,7 +23,14 @@ RangedConstraintManager::~RangedConstraintManager() {}
 ProgramStateRef RangedConstraintManager::assumeSym(ProgramStateRef State,
                                                    SymbolRef Sym,
                                                    bool Assumption) {
-  Sym = simplify(State, Sym);
+  SVal SimplifiedVal = simplifyToSVal(State, Sym);
+  if (SimplifiedVal.isConstant()) {
+    bool Feasible = SimplifiedVal.isZeroConstant() ? !Assumption : Assumption;
----------------
NagyDonat wrote:

```suggestion
    bool Feasible = SimplifiedVal.isZeroConstant() != Assumption;
```
In my opinion `!=` is probably the shortest and clearest way to represent the "these two booleans are different" (a.k.a XOR) relationship. (However, this is just subjective bikeshedding, and feel free to keep the `?:` if you think that it's better.)

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


More information about the cfe-commits mailing list