https://gcc.gnu.org/g:160a3995f4ccf007ca084cee44ca1be75d434182

commit r16-6824-g160a3995f4ccf007ca084cee44ca1be75d434182
Author: David Malcolm <[email protected]>
Date:   Fri Jan 16 10:54:32 2026 -0500

    analyzer: fix check against --param=analyzer-bb-explosion-factor=0
    
    analyzer.texi documents --param=analyzer-bb-explosion-factor=0 as a way
    to make the analysis bail out early, but I broke this in
    r16-6063-g0b786d961d4426.
    
    Fix thusly.
    
    gcc/analyzer/ChangeLog:
            * engine.cc (exploded_graph::process_worklist): Remove guard on
            limit being non-zero when checking for -Wanalyzer-too-complex
            on overall number of exploded nodes.  Allow for the origin enode.
    
    Signed-off-by: David Malcolm <[email protected]>

Diff:
---
 gcc/analyzer/engine.cc | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc
index 5222f9e32dd6..2d22abf05303 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -3400,19 +3400,22 @@ exploded_graph::process_worklist ()
       /* Impose a hard limit on the number of exploded nodes, to ensure
         that the analysis terminates in the face of pathological state
         explosion (or bugs).  */
-      if (const int limit
-           = m_sg.num_nodes () * param_analyzer_bb_explosion_factor)
-       if (m_global_stats.m_num_nodes > limit)
-         {
-           if (logger)
-             logger->log ("bailing out; too many nodes");
-           warning_at (node->get_point ().get_location (),
-                       OPT_Wanalyzer_too_complex,
-                       "analysis bailed out early"
-                       " (%i enodes)",
-                       m_nodes.length ());
-           return;
-         }
+      const int limit
+       = (// Per-supernode limit:
+          (m_sg.num_nodes () * param_analyzer_bb_explosion_factor)
+          // Allow one for the "origin" enode:
+          + 1);
+      if (m_global_stats.m_num_nodes > limit)
+       {
+         if (logger)
+           logger->log ("bailing out; too many nodes");
+         warning_at (node->get_point ().get_location (),
+                     OPT_Wanalyzer_too_complex,
+                     "analysis bailed out early"
+                     " (%i enodes)",
+                     m_nodes.length ());
+         return;
+       }
     }
 }

Reply via email to