public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-6376] analyzer: add region::is_named_decl_p
@ 2022-01-08 0:03 David Malcolm
0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2022-01-08 0:03 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:c1b7d28a5987e74232b7f054849f8bd8ccc7e7de
commit r12-6376-gc1b7d28a5987e74232b7f054849f8bd8ccc7e7de
Author: David Malcolm <dmalcolm@redhat.com>
Date: Fri Jan 7 13:49:28 2022 -0500
analyzer: add region::is_named_decl_p
This patch adds a debug function that I've found handy when debugging
a problem with handling the decl "yy_buffer_stack" in PR analyzer/103546.
gcc/analyzer/ChangeLog:
* region.cc (region::is_named_decl_p): New.
* region.h (region::is_named_decl_p): New decl.
gcc/ChangeLog:
* doc/analyzer.texi (Other Debugging Techniques): Document
region::is_named_decl_p.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diff:
---
gcc/analyzer/region.cc | 14 ++++++++++++++
gcc/analyzer/region.h | 2 ++
gcc/doc/analyzer.texi | 10 ++++++++++
3 files changed, 26 insertions(+)
diff --git a/gcc/analyzer/region.cc b/gcc/analyzer/region.cc
index befcaa495cd..161e7e1fb10 100644
--- a/gcc/analyzer/region.cc
+++ b/gcc/analyzer/region.cc
@@ -638,6 +638,20 @@ region::symbolic_for_unknown_ptr_p () const
return false;
}
+/* Return true if this is a region for a decl with name DECL_NAME.
+ Intended for use when debugging (for assertions and conditional
+ breakpoints). */
+
+DEBUG_FUNCTION bool
+region::is_named_decl_p (const char *decl_name) const
+{
+ if (tree decl = maybe_get_decl ())
+ if (DECL_NAME (decl)
+ && !strcmp (IDENTIFIER_POINTER (DECL_NAME (decl)), decl_name))
+ return true;
+ return false;
+}
+
/* region's ctor. */
region::region (complexity c, unsigned id, const region *parent, tree type)
diff --git a/gcc/analyzer/region.h b/gcc/analyzer/region.h
index fbb50a1817a..d97bbc1e3f1 100644
--- a/gcc/analyzer/region.h
+++ b/gcc/analyzer/region.h
@@ -189,6 +189,8 @@ public:
const complexity &get_complexity () const { return m_complexity; }
+ bool is_named_decl_p (const char *decl_name) const;
+
protected:
region (complexity c, unsigned id, const region *parent, tree type);
diff --git a/gcc/doc/analyzer.texi b/gcc/doc/analyzer.texi
index 657798101c2..62faac44d7f 100644
--- a/gcc/doc/analyzer.texi
+++ b/gcc/doc/analyzer.texi
@@ -545,3 +545,13 @@ and the exploded graph in compressed JSON form.
One approach when tracking down where a particular bogus state is
introduced into the @code{exploded_graph} is to add custom code to
@code{program_state::validate}.
+
+The debug function @code{region::is_named_decl_p} can be used when debugging,
+such as for assertions and conditional breakpoints. For example, when
+tracking down a bug in handling a decl called @code{yy_buffer_stack}, I
+temporarily added a:
+@smallexample
+ gcc_assert (!m_base_region->is_named_decl_p ("yy_buffer_stack"));
+@end smallexample
+to @code{binding_cluster::mark_as_escaped} to trap a point where
+@code{yy_buffer_stack} was mistakenly being treated as having escaped.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-08 0:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-08 0:03 [gcc r12-6376] analyzer: add region::is_named_decl_p 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).