Modernization; no functional change intended.
gcc/analyzer/ChangeLog:
* checker-event.cc (function_entry_event::get_meaning): Convert
diagnostic_event::meaning enums to enum class.
(cfg_edge_event::get_meaning): Likewise.
(call_event::get_meaning): Likewise.
(return_event::get_meaning): Likewise.
(start_consolidated_cfg_edges_event::get_meaning): Likewise.
(inlined_call_event::get_meaning): Likewise.
(warning_event::get_meaning): Likewise.
* sm-fd.cc (fd_diagnostic::get_meaning_for_state_change):
Likewise.
* sm-file.cc (file_diagnostic::get_meaning_for_state_change):
Likewise.
* sm-malloc.cc (malloc_diagnostic::get_meaning_for_state_change):
Likewise.
* sm-sensitive.cc
(exposure_through_output_file::get_meaning_for_state_change):
Likewise.
* sm-taint.cc (taint_diagnostic::get_meaning_for_state_change):
Likewise.
* varargs.cc
(va_list_sm_diagnostic::get_meaning_for_state_change): Likewise.
gcc/ChangeLog:
* diagnostic-format-sarif.cc
(sarif_builder::maybe_make_kinds_array): Convert
diagnostic_event::meaning enums to enum class.
* diagnostic-path-output.cc (path_label::get_text): Likewise.
* diagnostic-path.cc
(diagnostic_event::meaning::maybe_get_verb_str): Likewise.
(diagnostic_event::meaning::maybe_get_noun_str): Likewise.
(diagnostic_event::meaning::maybe_get_property_str): Likewise.
* diagnostic-path.h (diagnostic_event::verb): Likewise.
(diagnostic_event::noun): Likewise.
(diagnostic_event::property): Likewise.
(diagnostic_event::meaning): Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_gil_plugin.cc
(gil_diagnostic::get_meaning_for_state_change): Convert
diagnostic_event::meaning enums to enum class.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
diagnostic_event::meaning
function_entry_event::get_meaning () const
{
- return meaning (VERB_enter, NOUN_function);
+ return meaning (verb::enter, noun::function);
}
/* class state_change_event : public checker_event. */
{
const cfg_superedge& cfg_sedge = get_cfg_superedge ();
if (cfg_sedge.true_value_p ())
- return meaning (VERB_branch, PROPERTY_true);
+ return meaning (verb::branch, property::true_);
else if (cfg_sedge.false_value_p ())
- return meaning (VERB_branch, PROPERTY_false);
+ return meaning (verb::branch, property::false_);
else
return meaning ();
}
diagnostic_event::meaning
call_event::get_meaning () const
{
- return meaning (VERB_call, NOUN_function);
+ return meaning (verb::call, noun::function);
}
/* Override of checker_event::is_call_p for calls. */
diagnostic_event::meaning
return_event::get_meaning () const
{
- return meaning (VERB_return, NOUN_function);
+ return meaning (verb::return_, noun::function);
}
/* Override of checker_event::is_return_p for returns. */
diagnostic_event::meaning
start_consolidated_cfg_edges_event::get_meaning () const
{
- return meaning (VERB_branch,
- (m_edge_sense ? PROPERTY_true : PROPERTY_false));
+ return meaning (verb::branch,
+ (m_edge_sense ? property::true_ : property::false_));
}
/* class inlined_call_event : public checker_event. */
diagnostic_event::meaning
inlined_call_event::get_meaning () const
{
- return meaning (VERB_call, NOUN_function);
+ return meaning (verb::call, noun::function);
}
/* class setjmp_event : public checker_event. */
diagnostic_event::meaning
warning_event::get_meaning () const
{
- return meaning (VERB_danger, NOUN_unknown);
+ return meaning (verb::danger, noun::unknown);
}
const program_state *
|| change.m_new_state == m_sm.m_new_datagram_socket
|| change.m_new_state == m_sm.m_new_stream_socket
|| change.m_new_state == m_sm.m_new_unknown_socket))
- return diagnostic_event::meaning (diagnostic_event::VERB_acquire,
- diagnostic_event::NOUN_resource);
+ return diagnostic_event::meaning (diagnostic_event::verb::acquire,
+ diagnostic_event::noun::resource);
if (change.m_new_state == m_sm.m_closed)
- return diagnostic_event::meaning (diagnostic_event::VERB_release,
- diagnostic_event::NOUN_resource);
+ return diagnostic_event::meaning (diagnostic_event::verb::release,
+ diagnostic_event::noun::resource);
return diagnostic_event::meaning ();
}
{
if (change.m_old_state == m_sm.get_start_state ()
&& change.m_new_state == m_sm.m_unchecked)
- return diagnostic_event::meaning (diagnostic_event::VERB_acquire,
- diagnostic_event::NOUN_resource);
+ return diagnostic_event::meaning (diagnostic_event::verb::acquire,
+ diagnostic_event::noun::resource);
if (change.m_new_state == m_sm.m_closed)
- return diagnostic_event::meaning (diagnostic_event::VERB_release,
- diagnostic_event::NOUN_resource);
+ return diagnostic_event::meaning (diagnostic_event::verb::release,
+ diagnostic_event::noun::resource);
return diagnostic_event::meaning ();
}
{
if (change.m_old_state == m_sm.get_start_state ()
&& unchecked_p (change.m_new_state))
- return diagnostic_event::meaning (diagnostic_event::VERB_acquire,
- diagnostic_event::NOUN_memory);
+ return diagnostic_event::meaning (diagnostic_event::verb::acquire,
+ diagnostic_event::noun::memory);
if (freed_p (change.m_new_state))
- return diagnostic_event::meaning (diagnostic_event::VERB_release,
- diagnostic_event::NOUN_memory);
+ return diagnostic_event::meaning (diagnostic_event::verb::release,
+ diagnostic_event::noun::memory);
return diagnostic_event::meaning ();
}
const final override
{
if (change.m_new_state == m_sm.m_sensitive)
- return diagnostic_event::meaning (diagnostic_event::VERB_acquire,
- diagnostic_event::NOUN_sensitive);
+ return diagnostic_event::meaning (diagnostic_event::verb::acquire,
+ diagnostic_event::noun::sensitive);
return diagnostic_event::meaning ();
}
bool
const final override
{
if (change.m_new_state == m_sm.m_tainted)
- return diagnostic_event::meaning (diagnostic_event::VERB_acquire,
- diagnostic_event::NOUN_taint);
+ return diagnostic_event::meaning (diagnostic_event::verb::acquire,
+ diagnostic_event::noun::taint);
return diagnostic_event::meaning ();
}
const final override
{
if (change.m_new_state == m_sm.m_started)
- return diagnostic_event::meaning (diagnostic_event::VERB_acquire,
- diagnostic_event::NOUN_resource);
+ return diagnostic_event::meaning (diagnostic_event::verb::acquire,
+ diagnostic_event::noun::resource);
if (change.m_new_state == m_sm.m_ended)
- return diagnostic_event::meaning (diagnostic_event::VERB_release,
- diagnostic_event::NOUN_resource);
+ return diagnostic_event::meaning (diagnostic_event::verb::release,
+ diagnostic_event::noun::resource);
return diagnostic_event::meaning ();
}
std::unique_ptr<json::array>
sarif_builder::maybe_make_kinds_array (diagnostic_event::meaning m) const
{
- if (m.m_verb == diagnostic_event::VERB_unknown
- && m.m_noun == diagnostic_event::NOUN_unknown
- && m.m_property == diagnostic_event::PROPERTY_unknown)
+ if (m.m_verb == diagnostic_event::verb::unknown
+ && m.m_noun == diagnostic_event::noun::unknown
+ && m.m_property == diagnostic_event::property::unknown)
return nullptr;
auto kinds_arr = std::make_unique<json::array> ();
pp_printf (pp.get (), "%@", &event_id);
pp_space (pp.get ());
- if (meaning.m_verb == diagnostic_event::VERB_danger
+ if (meaning.m_verb == diagnostic_event::verb::danger
&& m_allow_emojis)
{
pp_unicode_character (pp.get (), 0x26A0); /* U+26A0 WARNING SIGN. */
{
default:
gcc_unreachable ();
- case VERB_unknown:
- return NULL;
- case VERB_acquire:
+ case verb::unknown:
+ return nullptr;
+ case verb::acquire:
return "acquire";
- case VERB_release:
+ case verb::release:
return "release";
- case VERB_enter:
+ case verb::enter:
return "enter";
- case VERB_exit:
+ case verb::exit:
return "exit";
- case VERB_call:
+ case verb::call:
return "call";
- case VERB_return:
+ case verb::return_:
return "return";
- case VERB_branch:
+ case verb::branch:
return "branch";
- case VERB_danger:
+ case verb::danger:
return "danger";
}
}
{
default:
gcc_unreachable ();
- case NOUN_unknown:
- return NULL;
- case NOUN_taint:
+ case noun::unknown:
+ return nullptr;
+ case noun::taint:
return "taint";
- case NOUN_sensitive:
+ case noun::sensitive:
return "sensitive";
- case NOUN_function:
+ case noun::function:
return "function";
- case NOUN_lock:
+ case noun::lock:
return "lock";
- case NOUN_memory:
+ case noun::memory:
return "memory";
- case NOUN_resource:
+ case noun::resource:
return "resource";
}
}
{
default:
gcc_unreachable ();
- case PROPERTY_unknown:
- return NULL;
- case PROPERTY_true:
+ case property::unknown:
+ return nullptr;
+ case property::true_:
return "true";
- case PROPERTY_false:
+ case property::false_:
return "false";
}
}
public:
/* Enums for giving a sense of what this event means.
Roughly corresponds to SARIF v2.1.0 section 3.38.8. */
- enum verb
+ enum class verb
{
- VERB_unknown,
+ unknown,
- VERB_acquire,
- VERB_release,
- VERB_enter,
- VERB_exit,
- VERB_call,
- VERB_return,
- VERB_branch,
+ acquire,
+ release,
+ enter,
+ exit,
+ call,
+ return_,
+ branch,
- VERB_danger
+ danger
};
- enum noun
+ enum class noun
{
- NOUN_unknown,
-
- NOUN_taint,
- NOUN_sensitive, // this one isn't in SARIF v2.1.0; filed as https://github.com/oasis-tcs/sarif-spec/issues/530
- NOUN_function,
- NOUN_lock,
- NOUN_memory,
- NOUN_resource
+ unknown,
+
+ taint,
+ sensitive, // this one isn't in SARIF v2.1.0; filed as https://github.com/oasis-tcs/sarif-spec/issues/530
+ function,
+ lock,
+ memory,
+ resource
};
- enum property
+ enum class property
{
- PROPERTY_unknown,
+ unknown,
- PROPERTY_true,
- PROPERTY_false
+ true_,
+ false_
};
/* A bundle of such enums, allowing for descriptions of the meaning of
an event, such as
- - "acquire memory": meaning (VERB_acquire, NOUN_memory)
- - "take true branch"": meaning (VERB_branch, PROPERTY_true)
- - "return from function": meaning (VERB_return, NOUN_function)
+ - "acquire memory": meaning (verb::acquire, noun::memory)
+ - "take true branch"": meaning (verb::branch, property::true)
+ - "return from function": meaning (verb::return, noun::function)
etc, as per SARIF's threadFlowLocation "kinds" property
(SARIF v2.1.0 section 3.38.8). */
struct meaning
{
meaning ()
- : m_verb (VERB_unknown),
- m_noun (NOUN_unknown),
- m_property (PROPERTY_unknown)
+ : m_verb (verb::unknown),
+ m_noun (noun::unknown),
+ m_property (property::unknown)
{
}
meaning (enum verb verb, enum noun noun)
- : m_verb (verb), m_noun (noun), m_property (PROPERTY_unknown)
+ : m_verb (verb), m_noun (noun), m_property (property::unknown)
{
}
meaning (enum verb verb, enum property property)
- : m_verb (verb), m_noun (NOUN_unknown), m_property (property)
+ : m_verb (verb), m_noun (noun::unknown), m_property (property)
{
}
if (change.is_global_p ())
{
if (change.m_new_state == m_sm.m_released_gil)
- return diagnostic_event::meaning (diagnostic_event::VERB_release,
- diagnostic_event::NOUN_lock);
+ return diagnostic_event::meaning (diagnostic_event::verb::release,
+ diagnostic_event::noun::lock);
else if (change.m_new_state == m_sm.get_start_state ())
- return diagnostic_event::meaning (diagnostic_event::VERB_acquire,
- diagnostic_event::NOUN_lock);
+ return diagnostic_event::meaning (diagnostic_event::verb::acquire,
+ diagnostic_event::noun::lock);
}
return diagnostic_event::meaning ();
}