[clang] [analyzer] Respect symbol complexity bound in tryRearrange (PR #227367)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 1 04:21:14 PDT 2026


================
@@ -289,14 +289,14 @@ static std::pair<SymbolRef, APSIntPtr> decomposeSymbol(SymbolRef Sym,
 
 // Simplify "(LSym + LInt) Op (RSym + RInt)" assuming all values are of the
 // same signed integral type and no overflows occur (which should be checked
-// by the caller).
-static NonLoc doRearrangeUnchecked(ProgramStateRef State,
-                                   BinaryOperator::Opcode Op,
-                                   SymbolRef LSym, llvm::APSInt LInt,
-                                   SymbolRef RSym, llvm::APSInt RInt) {
+// by the caller). May return UnknownVal if the symbol complexity threshold is
+// reached.
----------------
NagyDonat wrote:

It happens multiple times within the test file where I added the extra run line with `aggressive-binary-operation-simplification=true`.

Previously that test would have consumed a practically infinite amount of time with `aggressive-binary-operation-simplification=true` because it constructed symbols with exponentially increasing complexity. The fact that it now runs quickly even with this option shows that my change is effective.

(If you think it would be important, I could create a testcase that exercises this "return Unknown" case in a more isolated manner.)



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


More information about the cfe-commits mailing list