aboutsummaryrefslogtreecommitdiff
path: root/gcc/analyzer/sm-malloc.cc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2022-05-20 10:05:54 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2022-05-20 10:05:54 -0400
commitff171cb13df671a2a0647a68da0fdc1f9a78b8c9 (patch)
tree099c56c115ca15e17c84d4178b546191fdf0b2b1 /gcc/analyzer/sm-malloc.cc
parent6c420193e86b39a09304b2845335571eefe24d5d (diff)
downloadgcc-ff171cb13df671a2a0647a68da0fdc1f9a78b8c9.zip
gcc-ff171cb13df671a2a0647a68da0fdc1f9a78b8c9.tar.gz
gcc-ff171cb13df671a2a0647a68da0fdc1f9a78b8c9.tar.bz2
Use "final" and "override" directly, rather than via macros
As of GCC 11 onwards we have required a C++11 compiler, such as GCC 4.8 or later. On the assumption that any such compiler correctly implements "final" and "override", this patch updates the source tree to stop using the FINAL and OVERRIDE macros from ansidecl.h, in favor of simply using "final" and "override" directly. libcpp/ChangeLog: * lex.cc: Replace uses of "FINAL" and "OVERRIDE" with "final" and "override". gcc/analyzer/ChangeLog: * analyzer-pass.cc: Replace uses of "FINAL" and "OVERRIDE" with "final" and "override". * call-info.h: Likewise. * checker-path.h: Likewise. * constraint-manager.cc: Likewise. * diagnostic-manager.cc: Likewise. * engine.cc: Likewise. * exploded-graph.h: Likewise. * feasible-graph.h: Likewise. * pending-diagnostic.h: Likewise. * region-model-impl-calls.cc: Likewise. * region-model.cc: Likewise. * region-model.h: Likewise. * region.h: Likewise. * sm-file.cc: Likewise. * sm-malloc.cc: Likewise. * sm-pattern-test.cc: Likewise. * sm-sensitive.cc: Likewise. * sm-signal.cc: Likewise. * sm-taint.cc: Likewise. * state-purge.h: Likewise. * store.cc: Likewise. * store.h: Likewise. * supergraph.h: Likewise. * svalue.h: Likewise. * trimmed-graph.h: Likewise. * varargs.cc: Likewise. gcc/c-family/ChangeLog: * c-format.cc: Replace uses of "FINAL" and "OVERRIDE" with "final" and "override". * c-pretty-print.h: Likewise. gcc/cp/ChangeLog: * cxx-pretty-print.h: Replace uses of "FINAL" and "OVERRIDE" with "final" and "override". * error.cc: Likewise. gcc/jit/ChangeLog: * jit-playback.h: Replace uses of "FINAL" and "OVERRIDE" with "final" and "override". * jit-recording.cc: Likewise. * jit-recording.h: Likewise. gcc/ChangeLog: * config/aarch64/aarch64-sve-builtins-base.cc: Replace uses of "FINAL" and "OVERRIDE" with "final" and "override". * config/aarch64/aarch64-sve-builtins-functions.h: Likewise. * config/aarch64/aarch64-sve-builtins-shapes.cc: Likewise. * config/aarch64/aarch64-sve-builtins-sve2.cc: Likewise. * diagnostic-path.h: Likewise. * digraph.cc: Likewise. * gcc-rich-location.h: Likewise. * gimple-array-bounds.cc: Likewise. * gimple-loop-versioning.cc: Likewise. * gimple-range-cache.cc: Likewise. * gimple-range-cache.h: Likewise. * gimple-range-fold.cc: Likewise. * gimple-range-fold.h: Likewise. * gimple-range-tests.cc: Likewise. * gimple-range.h: Likewise. * gimple-ssa-evrp.cc: Likewise. * input.cc: Likewise. * json.h: Likewise. * read-rtl-function.cc: Likewise. * tree-complex.cc: Likewise. * tree-diagnostic-path.cc: Likewise. * tree-ssa-ccp.cc: Likewise. * tree-ssa-copy.cc: Likewise. * tree-vrp.cc: Likewise. * value-query.h: Likewise. * vr-values.h: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/analyzer/sm-malloc.cc')
-rw-r--r--gcc/analyzer/sm-malloc.cc130
1 files changed, 65 insertions, 65 deletions
diff --git a/gcc/analyzer/sm-malloc.cc b/gcc/analyzer/sm-malloc.cc
index 20c1677..abdce6b 100644
--- a/gcc/analyzer/sm-malloc.cc
+++ b/gcc/analyzer/sm-malloc.cc
@@ -128,7 +128,7 @@ struct allocation_state : public state_machine::state
m_deallocator (deallocator)
{}
- void dump_to_pp (pretty_printer *pp) const FINAL OVERRIDE;
+ void dump_to_pp (pretty_printer *pp) const final override;
const allocation_state *get_nonnull () const;
@@ -243,9 +243,9 @@ struct custom_deallocator_set : public deallocator_set
//unsigned arg_idx,
enum wording wording);
- bool contains_p (const deallocator *d) const FINAL OVERRIDE;
- const deallocator *maybe_get_single () const FINAL OVERRIDE;
- void dump_to_pp (pretty_printer *pp) const FINAL OVERRIDE;
+ bool contains_p (const deallocator *d) const final override;
+ const deallocator *maybe_get_single () const final override;
+ void dump_to_pp (pretty_printer *pp) const final override;
auto_vec <const deallocator *> m_deallocator_vec;
};
@@ -259,9 +259,9 @@ struct standard_deallocator_set : public deallocator_set
const char *name,
enum wording wording);
- bool contains_p (const deallocator *d) const FINAL OVERRIDE;
- const deallocator *maybe_get_single () const FINAL OVERRIDE;
- void dump_to_pp (pretty_printer *pp) const FINAL OVERRIDE;
+ bool contains_p (const deallocator *d) const final override;
+ const deallocator *maybe_get_single () const final override;
+ void dump_to_pp (pretty_printer *pp) const final override;
standard_deallocator m_deallocator;
};
@@ -343,10 +343,10 @@ public:
const deallocator_set *deallocators,
const deallocator *deallocator);
- bool inherited_state_p () const FINAL OVERRIDE { return false; }
+ bool inherited_state_p () const final override { return false; }
state_machine::state_t
- get_default_state (const svalue *sval) const FINAL OVERRIDE
+ get_default_state (const svalue *sval) const final override
{
if (tree cst = sval->maybe_get_constant ())
{
@@ -372,25 +372,25 @@ public:
bool on_stmt (sm_context *sm_ctxt,
const supernode *node,
- const gimple *stmt) const FINAL OVERRIDE;
+ const gimple *stmt) const final override;
void on_phi (sm_context *sm_ctxt,
const supernode *node,
const gphi *phi,
- tree rhs) const FINAL OVERRIDE;
+ tree rhs) const final override;
void on_condition (sm_context *sm_ctxt,
const supernode *node,
const gimple *stmt,
const svalue *lhs,
enum tree_code op,
- const svalue *rhs) const FINAL OVERRIDE;
+ const svalue *rhs) const final override;
- bool can_purge_p (state_t s) const FINAL OVERRIDE;
- pending_diagnostic *on_leak (tree var) const FINAL OVERRIDE;
+ bool can_purge_p (state_t s) const final override;
+ pending_diagnostic *on_leak (tree var) const final override;
bool reset_when_passed_to_unknown_fn_p (state_t s,
- bool is_mutable) const FINAL OVERRIDE;
+ bool is_mutable) const final override;
static bool unaffected_by_call_p (tree fndecl);
@@ -689,13 +689,13 @@ public:
: m_sm (sm), m_arg (arg)
{}
- bool subclass_equal_p (const pending_diagnostic &base_other) const OVERRIDE
+ bool subclass_equal_p (const pending_diagnostic &base_other) const override
{
return same_tree_p (m_arg, ((const malloc_diagnostic &)base_other).m_arg);
}
label_text describe_state_change (const evdesc::state_change &change)
- OVERRIDE
+ override
{
if (change.m_old_state == m_sm.get_start_state ()
&& unchecked_p (change.m_new_state))
@@ -755,17 +755,17 @@ public:
m_actual_dealloc (actual_dealloc)
{}
- const char *get_kind () const FINAL OVERRIDE
+ const char *get_kind () const final override
{
return "mismatching_deallocation";
}
- int get_controlling_option () const FINAL OVERRIDE
+ int get_controlling_option () const final override
{
return OPT_Wanalyzer_mismatching_deallocation;
}
- bool emit (rich_location *rich_loc) FINAL OVERRIDE
+ bool emit (rich_location *rich_loc) final override
{
auto_diagnostic_group d;
diagnostic_metadata m;
@@ -785,7 +785,7 @@ public:
}
label_text describe_state_change (const evdesc::state_change &change)
- FINAL OVERRIDE
+ final override
{
if (unchecked_p (change.m_new_state))
{
@@ -801,7 +801,7 @@ public:
return malloc_diagnostic::describe_state_change (change);
}
- label_text describe_final_event (const evdesc::final_event &ev) FINAL OVERRIDE
+ label_text describe_final_event (const evdesc::final_event &ev) final override
{
if (m_alloc_event.known_p ())
{
@@ -837,14 +837,14 @@ public:
: malloc_diagnostic (sm, arg), m_funcname (funcname)
{}
- const char *get_kind () const FINAL OVERRIDE { return "double_free"; }
+ const char *get_kind () const final override { return "double_free"; }
- int get_controlling_option () const FINAL OVERRIDE
+ int get_controlling_option () const final override
{
return OPT_Wanalyzer_double_free;
}
- bool emit (rich_location *rich_loc) FINAL OVERRIDE
+ bool emit (rich_location *rich_loc) final override
{
auto_diagnostic_group d;
diagnostic_metadata m;
@@ -854,7 +854,7 @@ public:
}
label_text describe_state_change (const evdesc::state_change &change)
- FINAL OVERRIDE
+ final override
{
if (freed_p (change.m_new_state))
{
@@ -865,7 +865,7 @@ public:
}
label_text describe_call_with_state (const evdesc::call_with_state &info)
- FINAL OVERRIDE
+ final override
{
if (freed_p (info.m_state))
return info.formatted_print
@@ -874,7 +874,7 @@ public:
return label_text ();
}
- label_text describe_final_event (const evdesc::final_event &ev) FINAL OVERRIDE
+ label_text describe_final_event (const evdesc::final_event &ev) final override
{
if (m_first_free_event.known_p ())
return ev.formatted_print ("second %qs here; first %qs was at %@",
@@ -899,7 +899,7 @@ public:
{}
label_text describe_state_change (const evdesc::state_change &change)
- FINAL OVERRIDE
+ final override
{
if (change.m_old_state == m_sm.get_start_state ()
&& unchecked_p (change.m_new_state))
@@ -911,7 +911,7 @@ public:
}
label_text describe_return_of_state (const evdesc::return_of_state &info)
- FINAL OVERRIDE
+ final override
{
if (unchecked_p (info.m_state))
return info.formatted_print ("possible return of NULL to %qE from %qE",
@@ -933,14 +933,14 @@ public:
: possible_null (sm, arg)
{}
- const char *get_kind () const FINAL OVERRIDE { return "possible_null_deref"; }
+ const char *get_kind () const final override { return "possible_null_deref"; }
- int get_controlling_option () const FINAL OVERRIDE
+ int get_controlling_option () const final override
{
return OPT_Wanalyzer_possible_null_dereference;
}
- bool emit (rich_location *rich_loc) FINAL OVERRIDE
+ bool emit (rich_location *rich_loc) final override
{
/* CWE-690: Unchecked Return Value to NULL Pointer Dereference. */
diagnostic_metadata m;
@@ -949,7 +949,7 @@ public:
"dereference of possibly-NULL %qE", m_arg);
}
- label_text describe_final_event (const evdesc::final_event &ev) FINAL OVERRIDE
+ label_text describe_final_event (const evdesc::final_event &ev) final override
{
if (m_origin_of_unchecked_event.known_p ())
return ev.formatted_print ("%qE could be NULL: unchecked value from %@",
@@ -1013,7 +1013,7 @@ public:
m_fndecl (fndecl), m_arg_idx (arg_idx)
{}
- const char *get_kind () const FINAL OVERRIDE { return "possible_null_arg"; }
+ const char *get_kind () const final override { return "possible_null_arg"; }
bool subclass_equal_p (const pending_diagnostic &base_other) const
{
@@ -1024,12 +1024,12 @@ public:
&& m_arg_idx == sub_other.m_arg_idx);
}
- int get_controlling_option () const FINAL OVERRIDE
+ int get_controlling_option () const final override
{
return OPT_Wanalyzer_possible_null_argument;
}
- bool emit (rich_location *rich_loc) FINAL OVERRIDE
+ bool emit (rich_location *rich_loc) final override
{
/* CWE-690: Unchecked Return Value to NULL Pointer Dereference. */
auto_diagnostic_group d;
@@ -1044,7 +1044,7 @@ public:
return warned;
}
- label_text describe_final_event (const evdesc::final_event &ev) FINAL OVERRIDE
+ label_text describe_final_event (const evdesc::final_event &ev) final override
{
label_text arg_desc = describe_argument_index (m_fndecl, m_arg_idx);
label_text result;
@@ -1074,14 +1074,14 @@ public:
null_deref (const malloc_state_machine &sm, tree arg)
: malloc_diagnostic (sm, arg) {}
- const char *get_kind () const FINAL OVERRIDE { return "null_deref"; }
+ const char *get_kind () const final override { return "null_deref"; }
- int get_controlling_option () const FINAL OVERRIDE
+ int get_controlling_option () const final override
{
return OPT_Wanalyzer_null_dereference;
}
- bool emit (rich_location *rich_loc) FINAL OVERRIDE
+ bool emit (rich_location *rich_loc) final override
{
/* CWE-476: NULL Pointer Dereference. */
diagnostic_metadata m;
@@ -1091,7 +1091,7 @@ public:
}
label_text describe_return_of_state (const evdesc::return_of_state &info)
- FINAL OVERRIDE
+ final override
{
if (info.m_state == m_sm.m_null)
return info.formatted_print ("return of NULL to %qE from %qE",
@@ -1099,7 +1099,7 @@ public:
return label_text ();
}
- label_text describe_final_event (const evdesc::final_event &ev) FINAL OVERRIDE
+ label_text describe_final_event (const evdesc::final_event &ev) final override
{
return ev.formatted_print ("dereference of NULL %qE", ev.m_expr);
}
@@ -1117,7 +1117,7 @@ public:
m_fndecl (fndecl), m_arg_idx (arg_idx)
{}
- const char *get_kind () const FINAL OVERRIDE { return "null_arg"; }
+ const char *get_kind () const final override { return "null_arg"; }
bool subclass_equal_p (const pending_diagnostic &base_other) const
{
@@ -1128,12 +1128,12 @@ public:
&& m_arg_idx == sub_other.m_arg_idx);
}
- int get_controlling_option () const FINAL OVERRIDE
+ int get_controlling_option () const final override
{
return OPT_Wanalyzer_null_argument;
}
- bool emit (rich_location *rich_loc) FINAL OVERRIDE
+ bool emit (rich_location *rich_loc) final override
{
/* CWE-476: NULL Pointer Dereference. */
auto_diagnostic_group d;
@@ -1153,7 +1153,7 @@ public:
return warned;
}
- label_text describe_final_event (const evdesc::final_event &ev) FINAL OVERRIDE
+ label_text describe_final_event (const evdesc::final_event &ev) final override
{
label_text arg_desc = describe_argument_index (m_fndecl, m_arg_idx);
label_text result;
@@ -1184,14 +1184,14 @@ public:
gcc_assert (deallocator);
}
- const char *get_kind () const FINAL OVERRIDE { return "use_after_free"; }
+ const char *get_kind () const final override { return "use_after_free"; }
- int get_controlling_option () const FINAL OVERRIDE
+ int get_controlling_option () const final override
{
return OPT_Wanalyzer_use_after_free;
}
- bool emit (rich_location *rich_loc) FINAL OVERRIDE
+ bool emit (rich_location *rich_loc) final override
{
/* CWE-416: Use After Free. */
diagnostic_metadata m;
@@ -1202,7 +1202,7 @@ public:
}
label_text describe_state_change (const evdesc::state_change &change)
- FINAL OVERRIDE
+ final override
{
if (freed_p (change.m_new_state))
{
@@ -1223,7 +1223,7 @@ public:
return malloc_diagnostic::describe_state_change (change);
}
- label_text describe_final_event (const evdesc::final_event &ev) FINAL OVERRIDE
+ label_text describe_final_event (const evdesc::final_event &ev) final override
{
const char *funcname = m_deallocator->m_name;
if (m_free_event.known_p ())
@@ -1259,7 +1259,7 @@ public:
that if they are accessed after the free, it looks like
they are uninitialized). */
- bool supercedes_p (const pending_diagnostic &other) const FINAL OVERRIDE
+ bool supercedes_p (const pending_diagnostic &other) const final override
{
if (other.use_of_uninit_p ())
return true;
@@ -1278,14 +1278,14 @@ public:
malloc_leak (const malloc_state_machine &sm, tree arg)
: malloc_diagnostic (sm, arg) {}
- const char *get_kind () const FINAL OVERRIDE { return "malloc_leak"; }
+ const char *get_kind () const final override { return "malloc_leak"; }
- int get_controlling_option () const FINAL OVERRIDE
+ int get_controlling_option () const final override
{
return OPT_Wanalyzer_malloc_leak;
}
- bool emit (rich_location *rich_loc) FINAL OVERRIDE
+ bool emit (rich_location *rich_loc) final override
{
diagnostic_metadata m;
m.add_cwe (401);
@@ -1298,7 +1298,7 @@ public:
}
label_text describe_state_change (const evdesc::state_change &change)
- FINAL OVERRIDE
+ final override
{
if (unchecked_p (change.m_new_state)
|| (start_p (change.m_old_state) && nonnull_p (change.m_new_state)))
@@ -1309,7 +1309,7 @@ public:
return malloc_diagnostic::describe_state_change (change);
}
- label_text describe_final_event (const evdesc::final_event &ev) FINAL OVERRIDE
+ label_text describe_final_event (const evdesc::final_event &ev) final override
{
if (ev.m_expr)
{
@@ -1343,22 +1343,22 @@ public:
{
}
- const char *get_kind () const FINAL OVERRIDE { return "free_of_non_heap"; }
+ const char *get_kind () const final override { return "free_of_non_heap"; }
bool subclass_equal_p (const pending_diagnostic &base_other) const
- FINAL OVERRIDE
+ final override
{
const free_of_non_heap &other = (const free_of_non_heap &)base_other;
return (same_tree_p (m_arg, other.m_arg)
&& m_freed_reg == other.m_freed_reg);
}
- int get_controlling_option () const FINAL OVERRIDE
+ int get_controlling_option () const final override
{
return OPT_Wanalyzer_free_of_non_heap;
}
- bool emit (rich_location *rich_loc) FINAL OVERRIDE
+ bool emit (rich_location *rich_loc) final override
{
auto_diagnostic_group d;
diagnostic_metadata m;
@@ -1387,17 +1387,17 @@ public:
}
label_text describe_state_change (const evdesc::state_change &)
- FINAL OVERRIDE
+ final override
{
return label_text::borrow ("pointer is from here");
}
- label_text describe_final_event (const evdesc::final_event &ev) FINAL OVERRIDE
+ label_text describe_final_event (const evdesc::final_event &ev) final override
{
return ev.formatted_print ("call to %qs here", m_funcname);
}
- void mark_interesting_stuff (interesting_t *interest) FINAL OVERRIDE
+ void mark_interesting_stuff (interesting_t *interest) final override
{
if (m_freed_reg)
interest->add_region_creation (m_freed_reg);