[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 24 05:57:38 PDT 2025


================
@@ -134,6 +137,101 @@ class SymbolConjured : public SymbolData {
   static constexpr bool classof(Kind K) { return K == ClassKind; }
 };
 
+/// A symbol representing the result of an expression that became too
+/// complicated. In other words, its complexity would have surpassed the
+/// MaxSymbolComplexity threshold.
+/// TODO: When the MaxSymbolComplexity is reached, we should propagate the taint
+/// info to it.
+class SymbolTooComplex final : public SymbolData {
+  // Pointer to either "SymExpr" or "APSInt".
+  const void *LHS;
+  const void *RHS = nullptr; // optional
+  QualType Ty;
+  using OpKindType = std::make_unsigned_t<
+      std::common_type_t<BinaryOperatorKind, UnaryOperatorKind>>;
+  OpKindType Op = 0;
----------------
balazs-benics-sonarsource wrote:

The substitute symbol of "x + y" should be different to "x * y". Consequently, the operation that we failed to construct due to hitting the complexity limit plays a part in the identity of the resulting substitute symbol.
I also need the type to fulfil the contract of SymExpr, aka. to implement the pure virtual `getType` method.

`RHS` is optional, as this symbol may be created instead of a `SymbolCast` or `UnarySymExpr` where there is only a single operand.

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


More information about the cfe-commits mailing list