public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-3769] analyzer: introduce succeed_or_fail_call_info
@ 2022-11-08 2:53 David Malcolm
0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2022-11-08 2:53 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:be9fdbda1cbcd6a35b05424679c6c059605b61cb
commit r13-3769-gbe9fdbda1cbcd6a35b05424679c6c059605b61cb
Author: David Malcolm <dmalcolm@redhat.com>
Date: Mon Nov 7 21:52:40 2022 -0500
analyzer: introduce succeed_or_fail_call_info
This makes some followup code much cleaner.
gcc/analyzer/ChangeLog:
* call-info.cc (success_call_info::get_desc): Delete.
(failed_call_info::get_desc): Likewise.
(succeed_or_fail_call_info::get_desc): New.
* call-info.h (class succeed_or_fail_call_info): New.
(class success_call_info): Convert to a subclass of
succeed_or_fail_call_info.
(class failed_call_info): Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diff:
---
gcc/analyzer/call-info.cc | 21 ++++++---------------
gcc/analyzer/call-info.h | 34 ++++++++++++++++++++++++++--------
2 files changed, 32 insertions(+), 23 deletions(-)
diff --git a/gcc/analyzer/call-info.cc b/gcc/analyzer/call-info.cc
index ffdab73b165..7a1c4edfcae 100644
--- a/gcc/analyzer/call-info.cc
+++ b/gcc/analyzer/call-info.cc
@@ -141,24 +141,15 @@ call_info::call_info (const call_details &cd)
gcc_assert (m_fndecl);
}
-/* class success_call_info : public call_info. */
-
-/* Implementation of call_info::get_desc vfunc for success_call_info. */
-
-label_text
-success_call_info::get_desc (bool can_colorize) const
-{
- return make_label_text (can_colorize, "when %qE succeeds", get_fndecl ());
-}
-
-/* class failed_call_info : public call_info. */
-
-/* Implementation of call_info::get_desc vfunc for failed_call_info. */
+/* class succeed_or_fail_call_info : public call_info. */
label_text
-failed_call_info::get_desc (bool can_colorize) const
+succeed_or_fail_call_info::get_desc (bool can_colorize) const
{
- return make_label_text (can_colorize, "when %qE fails", get_fndecl ());
+ if (m_success)
+ return make_label_text (can_colorize, "when %qE succeeds", get_fndecl ());
+ else
+ return make_label_text (can_colorize, "when %qE fails", get_fndecl ());
}
} // namespace ana
diff --git a/gcc/analyzer/call-info.h b/gcc/analyzer/call-info.h
index 4bb7dd7e198..2fd50776f0a 100644
--- a/gcc/analyzer/call-info.h
+++ b/gcc/analyzer/call-info.h
@@ -51,17 +51,36 @@ private:
};
/* Subclass of call_info for a "success" outcome of a call,
- adding a "when `FNDECL' succeeds" message.
+ adding either a
+ "when `FNDECL' succeeds" message (when 'success' is true)
+ or a
+ "when `FNDECL' fails" message (when 'success' is false).
This is still abstract: the custom_edge_info::update_model vfunc
must be implemented. */
-class success_call_info : public call_info
+class succeed_or_fail_call_info : public call_info
{
public:
label_text get_desc (bool can_colorize) const final override;
protected:
- success_call_info (const call_details &cd) : call_info (cd) {}
+ succeed_or_fail_call_info (const call_details &cd, bool success)
+ : call_info (cd), m_success (success) {}
+
+ bool m_success;
+};
+
+/* Subclass of call_info for a "success" outcome of a call,
+ adding a "when `FNDECL' succeeds" message.
+ This is still abstract: the custom_edge_info::update_model vfunc
+ must be implemented. */
+
+class success_call_info : public succeed_or_fail_call_info
+{
+protected:
+ success_call_info (const call_details &cd)
+ : succeed_or_fail_call_info (cd, true)
+ {}
};
/* Subclass of call_info for a "failure" outcome of a call,
@@ -69,13 +88,12 @@ protected:
This is still abstract: the custom_edge_info::update_model vfunc
must be implemented. */
-class failed_call_info : public call_info
+class failed_call_info : public succeed_or_fail_call_info
{
-public:
- label_text get_desc (bool can_colorize) const final override;
-
protected:
- failed_call_info (const call_details &cd) : call_info (cd) {}
+ failed_call_info (const call_details &cd)
+ : succeed_or_fail_call_info (cd, false)
+ {}
};
} // namespace ana
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-11-08 2:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-08 2:53 [gcc r13-3769] analyzer: introduce succeed_or_fail_call_info David Malcolm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).