aboutsummaryrefslogtreecommitdiff
path: root/gcc/analyzer/infinite-recursion.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/analyzer/infinite-recursion.cc')
-rw-r--r--gcc/analyzer/infinite-recursion.cc76
1 files changed, 29 insertions, 47 deletions
diff --git a/gcc/analyzer/infinite-recursion.cc b/gcc/analyzer/infinite-recursion.cc
index 42f87ed..b80b94a 100644
--- a/gcc/analyzer/infinite-recursion.cc
+++ b/gcc/analyzer/infinite-recursion.cc
@@ -18,28 +18,14 @@ You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
-#include "config.h"
-#define INCLUDE_VECTOR
-#include "system.h"
-#include "coretypes.h"
-#include "tree.h"
-#include "fold-const.h"
-#include "gcc-rich-location.h"
-#include "alloc-pool.h"
-#include "fibonacci_heap.h"
-#include "shortest-paths.h"
-#include "diagnostic-core.h"
-#include "diagnostic-event-id.h"
-#include "diagnostic-path.h"
-#include "function.h"
-#include "pretty-print.h"
-#include "sbitmap.h"
-#include "bitmap.h"
-#include "tristate.h"
-#include "ordered-hash-map.h"
-#include "selftest.h"
-#include "json.h"
-#include "analyzer/analyzer.h"
+#include "analyzer/common.h"
+
+#include "cfg.h"
+#include "gimple-iterator.h"
+#include "gimple-pretty-print.h"
+#include "cgraph.h"
+#include "digraph.h"
+
#include "analyzer/analyzer-logging.h"
#include "analyzer/call-string.h"
#include "analyzer/program-point.h"
@@ -49,17 +35,9 @@ along with GCC; see the file COPYING3. If not see
#include "analyzer/sm.h"
#include "analyzer/pending-diagnostic.h"
#include "analyzer/diagnostic-manager.h"
-#include "cfg.h"
-#include "basic-block.h"
-#include "gimple.h"
-#include "gimple-iterator.h"
-#include "gimple-pretty-print.h"
-#include "cgraph.h"
-#include "digraph.h"
#include "analyzer/supergraph.h"
#include "analyzer/program-state.h"
#include "analyzer/exploded-graph.h"
-#include "make-unique.h"
#include "analyzer/checker-path.h"
#include "analyzer/feasible-graph.h"
#include "diagnostic-format-sarif.h"
@@ -77,7 +55,7 @@ public:
: m_prev_entry_enode (prev_entry_enode),
m_new_entry_enode (new_entry_enode),
m_callee_fndecl (callee_fndecl),
- m_prev_entry_event (NULL)
+ m_prev_entry_event (nullptr)
{}
const char *get_kind () const final override
@@ -130,9 +108,10 @@ public:
{
public:
recursive_function_entry_event (const program_point &dst_point,
+ const program_state &dst_state,
const infinite_recursion_diagnostic &pd,
bool topmost)
- : function_entry_event (dst_point),
+ : function_entry_event (dst_point, dst_state),
m_pd (pd),
m_topmost (topmost)
{
@@ -168,16 +147,19 @@ public:
const program_point &dst_point = dst_node->get_point ();
if (eedge.m_dest == m_prev_entry_enode)
{
- gcc_assert (m_prev_entry_event == NULL);
+ gcc_assert (m_prev_entry_event == nullptr);
std::unique_ptr<checker_event> prev_entry_event
- = make_unique <recursive_function_entry_event> (dst_point,
- *this, false);
+ = std::make_unique <recursive_function_entry_event>
+ (dst_point,
+ dst_node->get_state (),
+ *this, false);
m_prev_entry_event = prev_entry_event.get ();
emission_path->add_event (std::move (prev_entry_event));
}
else if (eedge.m_dest == m_new_entry_enode)
emission_path->add_event
- (make_unique<recursive_function_entry_event> (dst_point, *this, true));
+ (std::make_unique<recursive_function_entry_event>
+ (dst_point, dst_node->get_state (), *this, true));
else
pending_diagnostic::add_function_entry_event (eedge, emission_path);
}
@@ -193,7 +175,7 @@ public:
{
gcc_assert (m_new_entry_enode);
emission_path->add_event
- (make_unique<warning_event>
+ (std::make_unique<warning_event>
(event_loc_info (m_new_entry_enode->get_supernode
()->get_start_location (),
m_callee_fndecl,
@@ -309,7 +291,7 @@ private:
bool m_found_conjured_svalues;
};
- const svalue *sval = model.get_rvalue (expr, NULL);
+ const svalue *sval = model.get_rvalue (expr, nullptr);
conjured_svalue_finder v;
sval->accept (&v);
return v.m_found_conjured_svalues;
@@ -369,7 +351,7 @@ exploded_graph::find_previous_entry_to (function *top_of_stack_fun,
}
/* Not found. */
- return NULL;
+ return nullptr;
}
/* Given BASE_REG within ENCLOSING_FRAME (such as a function parameter),
@@ -403,7 +385,7 @@ remap_enclosing_frame (const region *base_reg,
const decl_region *decl_reg = (const decl_region *)base_reg;
return equiv_prev_frame->get_region_for_local (mgr,
decl_reg->get_decl (),
- NULL);
+ nullptr);
}
}
}
@@ -445,7 +427,7 @@ sufficiently_different_region_binding_p (exploded_node *new_entry_enode,
/* Get the value within the new frame. */
const svalue *new_sval
- = new_model.get_store_value (base_reg, NULL);
+ = new_model.get_store_value (base_reg, nullptr);
/* If any part of the value is UNKNOWN (e.g. due to hitting
complexity limits) assume that it differs from the previous
@@ -465,7 +447,7 @@ sufficiently_different_region_binding_p (exploded_node *new_entry_enode,
to the recursion. */
const int old_stack_depth = prev_entry_enode->get_stack_depth ();
if (enclosing_frame->get_stack_depth () < old_stack_depth)
- prev_sval = prev_model.get_store_value (base_reg, NULL);
+ prev_sval = prev_model.get_store_value (base_reg, nullptr);
else
{
/* Ignore bindings within frames below the new entry node. */
@@ -487,11 +469,11 @@ sufficiently_different_region_binding_p (exploded_node *new_entry_enode,
equiv_prev_frame,
new_model.get_manager ());
prev_sval
- = prev_model.get_store_value (equiv_prev_base_reg, NULL);
+ = prev_model.get_store_value (equiv_prev_base_reg, nullptr);
}
}
else
- prev_sval = prev_model.get_store_value (base_reg, NULL);
+ prev_sval = prev_model.get_store_value (base_reg, nullptr);
/* If the prev_sval contains UNKNOWN (e.g. due to hitting complexity limits)
assume that it will differ from any new value. */
@@ -645,7 +627,7 @@ exploded_graph::detect_infinite_recursion (exploded_node *enode)
nullptr);
get_diagnostic_manager ().add_diagnostic
(ploc,
- make_unique<infinite_recursion_diagnostic> (prev_entry_enode,
- enode,
- fndecl));
+ std::make_unique<infinite_recursion_diagnostic> (prev_entry_enode,
+ enode,
+ fndecl));
}