LCOV - code coverage report
Current view: top level - gcc/analyzer - symbolic-nodes.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 90.6 % 117 106
Test Date: 2026-11-14 16:39:50 Functions: 26.4 % 87 23
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Base class for svalues and regions.
       2              :    Copyright (C) 2023-2026 Free Software Foundation, Inc.
       3              :    Contributed by David Malcolm <dmalcolm@redhat.com>.
       4              : 
       5              : This file is part of GCC.
       6              : 
       7              : GCC is free software; you can redistribute it and/or modify it
       8              : under the terms of the GNU General Public License as published by
       9              : the Free Software Foundation; either version 3, or (at your option)
      10              : any later version.
      11              : 
      12              : GCC is distributed in the hope that it will be useful, but
      13              : WITHOUT ANY WARRANTY; without even the implied warranty of
      14              : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15              : General Public License for more details.
      16              : 
      17              : You should have received a copy of the GNU General Public License
      18              : along with GCC; see the file COPYING3.  If not see
      19              : <http://www.gnu.org/licenses/>.  */
      20              : 
      21              : #ifndef GCC_ANALYZER_SYMBOLIC_NODES_H
      22              : #define GCC_ANALYZER_SYMBOLIC_NODES_H
      23              : 
      24              : #include "pretty-print-markup.h"
      25              : 
      26              : #include "analyzer/analyzer-logging.h"
      27              : #include "analyzer/complexity.h"
      28              : #include "analyzer/units.h"
      29              : #include "analyzer/integer-with-unit.h"
      30              : 
      31              : #include "text-art/tree-widget.h"
      32              : #include "text-art/dump.h"
      33              : 
      34              : namespace ana {
      35              : namespace symbolic {
      36              : 
      37              : /* A central hub for managing symbolic::node instances
      38              :    - Provides a central authority for handing out IDs for new nodes.
      39              :    - Owns the various managers of symbolic::node subclasses and provides
      40              :    a central place for them to find each other.
      41              : 
      42              :    We use pointers to the managers to minimize compile-time dependencies.
      43              : 
      44              :    This is effectively a singleton during analysis (but each unit test
      45              :    gets its own instance).  */
      46              : 
      47              : class node_manager
      48              : {
      49              : public:
      50              :   node_manager ();
      51              :   ~node_manager ();
      52              : 
      53              :   node_manager (const node_manager &) = delete;
      54              : 
      55              :   unsigned get_num_nodes () const { return m_next_node_id; }
      56      1651639 :   unsigned alloc_node_id () { return m_next_node_id++; }
      57              : 
      58              :   region_model_manager &
      59      8839806 :   get_region_model_manager () const { return *m_rmm; }
      60              : 
      61              :   region_model_manager &
      62       263204 :   get_svalue_manager () const { return *m_rmm; }
      63              : 
      64              :   symbolic::bit_contents_manager &
      65      3042809 :   get_bit_contents_manager () const { return *m_bit_contents_manager; }
      66              : 
      67              :   symbolic::bit_vector_manager &
      68      4776096 :   get_bit_vector_manager () const { return *m_bit_vector_manager; }
      69              : 
      70              :   symbolic::scalar_managers &
      71     14181283 :   get_scalars () const { return *m_scalar_managers; }
      72              : 
      73              :   void log_stats (logger *logger, bool show_objs) const;
      74              : 
      75              : private:
      76              :   unsigned m_next_node_id;
      77              : 
      78              :   std::unique_ptr<symbolic::scalar_managers> m_scalar_managers;
      79              :   std::unique_ptr<region_model_manager> m_rmm;
      80              :   std::unique_ptr<symbolic::bit_contents_manager> m_bit_contents_manager;
      81              :   std::unique_ptr<symbolic::bit_vector_manager> m_bit_vector_manager;
      82              : };
      83              : 
      84              : /* A bundle of information for use by symbolic::node's
      85              :    make_markup_node vfunc.  */
      86              : 
      87              : struct markup_context
      88              : {
      89          229 :   markup_context (const region_model *model,
      90              :                   bool user_facing)
      91          229 :   : m_model (model),
      92          229 :     m_user_facing (user_facing)
      93              :   {
      94              :   }
      95              : 
      96              :   const region_model *m_model;
      97              :   bool m_user_facing;
      98              : };
      99              : 
     100              : /* Abstract base class for the various tree-like purely-functional
     101              :    data structures we use during symbolic execution.
     102              : 
     103              :    Instances are owned by a manager and reused, with memoization/caching
     104              :    (compare to "hash consing" and value numbering).
     105              : 
     106              :    Instances have a complexity and a numeric ID.
     107              : 
     108              :    Has hierarchical dumping for debugging how nodes are built from other
     109              :    nodes.
     110              : 
     111              :    Has a node_visitor class for walking the object hierarchy.
     112              : 
     113              :    Can convert itself to json for debugging/SARIF.  */
     114              : 
     115              : class node
     116              : {
     117              :  public:
     118              :   using id_t = unsigned;
     119              : 
     120       255877 :   virtual ~node () = default;
     121              : 
     122              :   /* Instances are managed via one of the managers within node_manager
     123              :      and thus shouldn't be copied/assigned.  */
     124              :   node (const node &) = delete;
     125              :   node (node &&) = delete;
     126              :   node &operator= (const node &) = delete;
     127              :   node &operator= (node &&) = delete;
     128              : 
     129      3101535 :   const complexity &get_complexity () const { return m_complexity; }
     130              : 
     131     91904352 :   id_t get_id () const { return m_id; }
     132              :   static int cmp_ids (const symbolic::node *s1, const symbolic::node *s2);
     133     81522071 :   static int cmp (const symbolic::node &s1, const symbolic::node &s2)
     134              :   {
     135     73869710 :     return (int)s1.get_id () - (int)s2.get_id ();
     136              :   }
     137              :   static int cmp_ptr_ptr (const void *, const void *);
     138              : 
     139              :   void dump_to_pp (pretty_printer *pp,
     140              :                    bool show_ids = true,
     141              :                    bool elide_repeated_nodes = true) const;
     142              :   void dump_to_logger (logger &) const;
     143              :   void dump () const;
     144              : 
     145              :   std::unique_ptr<text_art::tree_widget>
     146              :   make_dump_widget (node_dump_state &nds,
     147              :                     const char *prefix = nullptr) const;
     148              : 
     149              :   virtual const char *
     150            0 :   get_any_dump_color () const { return nullptr; }
     151              : 
     152              :   virtual void
     153              :   accept_node_visitor (node_visitor &v) const = 0;
     154              : 
     155              :   virtual std::unique_ptr<json::object>
     156              :   to_json () const = 0;
     157              : 
     158              :   virtual std::unique_ptr<diagnostics::markup::node>
     159              :   make_markup_node (markup_context &markup_ctxt) const = 0;
     160              : 
     161              :   bool involves_p (const symbolic::node &other) const;
     162              : 
     163              :   void
     164              :   start_any_dump_color (pretty_printer *pp) const;
     165              : 
     166              :   void
     167              :   end_any_dump_color (pretty_printer *pp) const;
     168              : 
     169              :   text_art::style
     170              :   get_text_art_tree_style () const;
     171              : 
     172              :  protected:
     173      3047921 :   node (complexity c, unsigned id)
     174      3047921 :   : m_complexity (c),
     175      3023468 :     m_id (id)
     176              :   {}
     177              : 
     178              :   std::unique_ptr<json::object>
     179              :   make_json_obj (const char *type_name) const;
     180              : 
     181              :  private:
     182              :   virtual void
     183              :   print_dump_widget_label (pretty_printer *pp) const = 0;
     184              :   virtual void
     185              :   add_dump_widget_children (text_art::tree_widget &,
     186              :                             node_dump_state &nds) const = 0;
     187              : 
     188              :   complexity m_complexity;
     189              :   id_t m_id; // for deterministic sorting at this stage, for dumps
     190              : };
     191              : 
     192              : struct CompareNodeIds
     193              : {
     194    960696372 :   bool operator()(const node *lhs, const node *rhs) const
     195              :   {
     196    960696372 :     return node::cmp_ids (lhs, rhs) < 0;
     197              :   }
     198              : };
     199              : 
     200              : /* A pp_element subclass for printing a symbolic::node in pp_printf via %e.
     201              :    This uses node::make_markup_node, lowers that, and prints the result
     202              :    to the pretty_printer.  */
     203              : 
     204           12 : class pp_element_for_node : public pp_element
     205              : {
     206              : public:
     207           12 :   pp_element_for_node (const node &n, bool user_facing = true)
     208           12 :   : m_node (n),
     209           12 :     m_user_facing (user_facing)
     210              :   {
     211              :   }
     212              : 
     213              :   void add_to_phase_2 (pp_markup::context &ctxt) final override;
     214              : 
     215              : private:
     216              :   const node &m_node;
     217              :   bool m_user_facing;
     218              : };
     219              : 
     220              : /* A set of symbolic::node instances.  */
     221              : 
     222              : template <typename NodeClass>
     223      9854432 : class node_set : public std::set<const NodeClass *, CompareNodeIds>
     224              : {
     225              : public:
     226      9817094 :   void add (const NodeClass *n)
     227              :   {
     228      9817094 :     gcc_assert (n);
     229      9817094 :     this->insert (n);
     230      9817094 :   }
     231              :   bool contains (const NodeClass *n) const;
     232              : 
     233              :   node_set<NodeClass>
     234              :   union_ (const node_set<NodeClass> &other) const;
     235              : 
     236              :   std::unique_ptr<text_art::tree_widget>
     237              :   make_dump_widget (node_dump_state &nds,
     238              :                     const char *prefix = nullptr) const;
     239              : 
     240              :   void dump_to_pp (pretty_printer *pp,
     241              :                    bool show_ids = true,
     242              :                    bool elide_repeated_nodes = true) const;
     243              :   void dump () const;
     244              : 
     245              :   bool operator< (const node_set<NodeClass> &other) const;
     246              : };
     247              : 
     248              : template <typename NodeClass>
     249              : node_set<NodeClass>
     250        43809 : node_set<NodeClass>::union_ (const node_set<NodeClass> &other) const
     251              : {
     252        43809 :   node_set<NodeClass> result (*this);
     253        83782 :   for (auto iter : other)
     254        39973 :     result.add (iter);
     255        43809 :   return result;
     256              : }
     257              : 
     258              : template <typename NodeClass>
     259              : inline bool
     260       482904 : node_set<NodeClass>::operator< (const node_set<NodeClass> &other) const
     261              : {
     262       482904 :   if (this->size () != other.size ())
     263       199939 :     return this->size () < other.size ();
     264       282965 :   auto this_iter = this->begin ();
     265       282965 :   auto other_iter = other.begin ();
     266       589056 :   for (; this_iter != this->end (); ++this_iter, ++other_iter)
     267       340056 :     if (*this_iter != *other_iter)
     268        33965 :       return (*this_iter)->get_id () < (*other_iter)->get_id ();
     269              :   return false;
     270              : }
     271              : 
     272              : /* A bundle of state for generating a hierarchical dump of one
     273              :    of more symbolic::node instances.  */
     274              : 
     275         2729 : struct node_dump_state : public text_art::dump_widget_info
     276              : {
     277         2729 :   node_dump_state (text_art::style_manager &sm,
     278              :                    const text_art::theme &theme,
     279              :                    text_art::style::id_t tree_style_id,
     280              :                    bool show_ids,
     281              :                    bool elide_repeated_nodes)
     282              :   : dump_widget_info (sm, theme, tree_style_id),
     283         2729 :     m_show_ids (show_ids),
     284         2729 :     m_elide_repeated_nodes (elide_repeated_nodes)
     285              :   {
     286              :   }
     287              : 
     288              :   /* Whether to show node IDs in dumps.
     289              :      - True is useful for debugging
     290              :      - false is useful for repeatable unit tests of dumping.  */
     291              :   bool m_show_ids;
     292              : 
     293              :   /* If true, then if a node appears more than once in a dump,
     294              :      only show its descendents the first time, showing a summary of its
     295              :      children for repeated occurrences.  */
     296              :   bool m_elide_repeated_nodes;
     297              : 
     298              :   /* State for implementing m_elide_repeated_nodes.  */
     299              :   node_set<symbolic::node> m_nodes_seen;
     300              : };
     301              : 
     302              : /* Dump a tree-like representation of OBJ and its constituent symbolic::nodes
     303              :    to PP.
     304              : 
     305              :    For example:
     306              :    . (gdb) call index_sval->dump()
     307              :    . (27): ‘int’: initial_svalue
     308              :    . ╰─ m_reg: (26): ‘int’: decl_region(‘x_10(D)’)
     309              :    .    ╰─ parent: (9): frame_region(‘test_bitmask_2’, index: 0, depth: 1)
     310              :    .       ╰─ parent: (1): stack region
     311              :    .          ╰─ parent: (0): root region
     312              : 
     313              :    Note that OBJ is not necessarily itself a symbolic::node, it just needs
     314              :    to implement make_dump_widget.
     315              : 
     316              :    Set show_ids to false for generating repeatable output (e.g. for unit
     317              :    testing of dump output).  */
     318              : 
     319              : template <typename T>
     320         1216 : void dump_node_tree_to_pp (const T &obj,
     321              :                            const text_art::theme *theme,
     322              :                            pretty_printer *pp,
     323              :                            bool show_ids,
     324              :                            bool elide_repeated_nodes)
     325              : {
     326         1216 :   if (!theme)
     327         1062 :     return;
     328              : 
     329              :   using namespace text_art;
     330              : 
     331          154 :   style_manager sm;
     332          154 :   style tree_style (get_style_from_color_cap_name ("note"));
     333              : 
     334          154 :   style::id_t tree_style_id (sm.get_or_create_id (tree_style));
     335              : 
     336          154 :   node_dump_state nds (sm, *theme, tree_style_id,
     337              :                        show_ids, elide_repeated_nodes);
     338          308 :   if (std::unique_ptr<widget> w = obj.make_dump_widget (nds))
     339              :     {
     340          154 :       text_art::canvas c (w->to_canvas (nds.m_sm));
     341          154 :       c.print_to_pp (pp);
     342          154 :     }
     343          154 : }
     344              : 
     345              : /* Dump OBJ to OUTF, using OBJ's make_dump_widget member function,
     346              :    global_dc's color/theme options, with symbol IDs shown,
     347              :    and eliding repeated occurrences of nodes.  */
     348              : 
     349              : template <typename T>
     350            0 : void dump_node_tree_to_file (const T &obj, FILE *outf)
     351              : {
     352            0 :   tree_dump_pretty_printer pp (outf);
     353            0 :   const text_art::theme *theme = global_dc->get_diagram_theme ();
     354            0 :   dump_node_tree_to_pp<T> (obj, theme, &pp, true, true);
     355            0 : }
     356              : 
     357              : /* Dump a tree-like representation of OBJ and its constituent symbolic::nodes
     358              :    to stderr, using global_dc's colorization and theming options, with
     359              :    symbolic::node IDs shown.
     360              : 
     361              :    For example:
     362              :    . (gdb) call reg->dump()
     363              :    . (26): ‘int’: decl_region(‘x_10(D)’)
     364              :    . ╰─ parent: (9): frame_region(‘test_bitmask_2’, index: 0, depth: 1)
     365              :    .    ╰─ parent: (1): stack region
     366              :    .       ╰─ parent: (0): root region
     367              : 
     368              :    Note that OBJ is not necessarily itself a symbolic::node, it just needs
     369              :    to implement make_dump_widget.  */
     370              : 
     371              : template <typename T>
     372            0 : void dump_node_tree_to_stderr (const T &obj)
     373              : {
     374            0 :   dump_node_tree_to_file<T> (obj, stderr);
     375            0 : }
     376              : 
     377              : /* As dump_node_tree_to_pp, but write to LOG, indenting the whole output
     378              :    according to the current nesting level of the log.  */
     379              : 
     380              : template <typename T>
     381         1862 : void dump_node_tree_to_logger (const T &obj,
     382              :                                logger &log,
     383              :                                const text_art::theme *theme,
     384              :                                bool show_ids,
     385              :                                bool elide_repeated_nodes)
     386              : {
     387         1862 :   if (!theme)
     388            0 :     return;
     389              : 
     390              :   using namespace text_art;
     391              : 
     392         1862 :   style_manager sm;
     393         1862 :   style tree_style (get_style_from_color_cap_name ("note"));
     394              : 
     395         1862 :   style::id_t tree_style_id (sm.get_or_create_id (tree_style));
     396              : 
     397         1862 :   node_dump_state nds (sm, *theme, tree_style_id,
     398              :                        show_ids, elide_repeated_nodes);
     399         3724 :   if (std::unique_ptr<widget> w = obj.make_dump_widget (nds))
     400              :     {
     401         1862 :       text_art::canvas c (w->to_canvas (nds.m_sm));
     402         1862 :       log.log_canvas (c);
     403         1862 :     }
     404         1862 : }
     405              : 
     406              : /* As above, but pass LABEL to OBJ's make_dump_widget call.  */
     407              : 
     408              : template <typename T>
     409          713 : void dump_node_tree_to_logger (const T &obj,
     410              :                                logger &log,
     411              :                                const text_art::theme *theme,
     412              :                                const char *label,
     413              :                                bool show_ids,
     414              :                                bool elide_repeated_nodes)
     415              : {
     416          713 :   if (!theme)
     417            0 :     return;
     418              : 
     419              :   using namespace text_art;
     420              : 
     421          713 :   style_manager sm;
     422          713 :   style tree_style (get_style_from_color_cap_name ("note"));
     423              : 
     424          713 :   style::id_t tree_style_id (sm.get_or_create_id (tree_style));
     425              : 
     426          713 :   node_dump_state nds (sm, *theme, tree_style_id,
     427              :                        show_ids, elide_repeated_nodes);
     428         1426 :   if (std::unique_ptr<widget> w = obj.make_dump_widget (nds, label))
     429              :     {
     430          713 :       text_art::canvas c (w->to_canvas (nds.m_sm));
     431          713 :       log.log_canvas (c);
     432          713 :     }
     433          713 : }
     434              : 
     435              : /* Dump a tree-like representation of OBJ and its constituent symbolic::nodes
     436              :    to LOG with symbol IDs shown.  */
     437              : 
     438              : template <typename T>
     439         1862 : void dump_node_tree_to_logger (const T &obj,
     440              :                                logger &log)
     441              : {
     442         1862 :   dump_node_tree_to_logger<T> (obj, log, log.get_text_art_theme (),
     443              :                                true, true);
     444         1862 : }
     445              : 
     446              : /* As above, but pass LABEL to OBJ's make_dump_widget call.  */
     447              : 
     448              : template <typename T>
     449          713 : void dump_node_tree_to_logger (const T &obj,
     450              :                                logger &log,
     451              :                                const char *label)
     452              : {
     453          713 :   dump_node_tree_to_logger<T> (obj, log, log.get_text_art_theme (),
     454              :                                label, true, true);
     455          713 : }
     456              : 
     457              : class value_node;
     458              : 
     459              : } // namespace symbolic
     460              : 
     461              : using value_set = symbolic::node_set<symbolic::value_node>;
     462              : 
     463              : namespace symbolic {
     464              : 
     465              : /* Intermediate base class for values that can be live or dead.  */
     466              : 
     467           76 : class value_node : public node
     468              : {
     469              : public:
     470              :   virtual bool implicitly_live_p (liveness_context &liveness_ctxt) const;
     471              : 
     472              :   virtual const svalue *
     473     14292242 :   dyn_cast_svalue () const { return nullptr; }
     474              : 
     475              :   virtual const bit_vector *
     476     89752298 :   dyn_cast_bit_vector () const { return nullptr; }
     477              : 
     478              :   virtual iter_result
     479              :   for_each_svalue (iter_result (*cb) (const svalue &sval,
     480              :                                       void *user_data),
     481              :                    void *user_data) const = 0;
     482              : 
     483              : protected:
     484      2679250 :   value_node (complexity c, unsigned id)
     485      1377615 :   : node (c, id)
     486              :   {}
     487              : 
     488              :   std::unique_ptr<json::object>
     489          941 :   make_json_obj (const char *type_name) const
     490              :   {
     491          941 :     return node::make_json_obj (type_name);
     492              :   }
     493              : };
     494              : 
     495              : /* Base class for traversing the nodes in a node hierarchy
     496              :    Subclasses should chain up the method calls. so that visit_node
     497              :    is called for all of them.
     498              :    visit_* methods should return true iff the traversal should continue
     499              :    into child nodes.  */
     500              : 
     501     24334763 : class node_visitor
     502              : {
     503              : public:
     504     24299412 :   virtual ~node_visitor () = default;
     505              : 
     506              :   virtual bool
     507    248492527 :   visit_node (const node &)
     508              :   {
     509              :     // No-op
     510    248492527 :     return true;
     511              :   }
     512              : 
     513              :   virtual bool
     514              :   visit_bit_contents (const bit_contents &n);
     515              : 
     516              :   virtual bool
     517              :   visit_bit_vector (const bit_vector &);
     518              : 
     519              :   virtual bool
     520              :   visit_region (const region &);
     521              : 
     522              :   virtual bool
     523              :   visit_scalar_unitless (const scalar<integer> &);
     524              : 
     525              :   virtual bool
     526              :   visit_scalar_bit (const scalar<integer_with_unit<units::bit>> &);
     527              : 
     528              :   virtual bool
     529              :   visit_scalar_byte (const scalar<integer_with_unit<units::byte>> &n);
     530              : 
     531              :   virtual bool
     532              :   visit_svalue (const svalue &n);
     533              : };
     534              : 
     535              : /* A node_visitor subclass that calls a callback on any value_node
     536              :    instances.  */
     537              : 
     538     23502881 : class value_node_visitor : public node_visitor
     539              : {
     540              : public:
     541     23502881 :   value_node_visitor (bool (*cb) (const value_node &val,
     542              :                                   void *user_data),
     543              :                       void *user_data)
     544     23502881 :     : m_cb (cb),
     545     23502881 :       m_user_data (user_data)
     546              :   {
     547              :   }
     548              : 
     549              :   bool visit_bit_vector (const bit_vector &bv) final override;
     550              :   bool visit_svalue (const svalue &sval) final override;
     551              : 
     552              : private:
     553              :   bool (*m_cb) (const value_node &val, void *user_data);
     554              :   void *m_user_data;
     555              : };
     556              : 
     557              : /* A (base region, baseline_state) pair for identifying a
     558              :    baseline bit_contents or baseline bit_vector.  */
     559              : 
     560              : struct baseline_key
     561              : {
     562              :   const region *m_base_reg;
     563              :   baseline_state m_baseline_state;
     564              : 
     565              :   bool
     566              :   operator< (const baseline_key &other) const;
     567              : 
     568              :   bool
     569              :   region_has_meaningful_size_p (symbolic::node_manager &node_mgr) const;
     570              : 
     571              :   std::unique_ptr<json::object>
     572              :   to_json () const;
     573              : };
     574              : 
     575              : } // namespace ana::symbolic
     576              : 
     577              : /* A bundle of state for purging information from a program_state about
     578              :    a conjured_bit_vector or conjured_bit_contents.  We pass this whenever
     579              :    we could need to create one of these, so that if the program_state already
     580              :    has information about this conjured value_node on an execution path, we
     581              :    can purge that information, to avoid the analyzer confusing the two
     582              :    interpretations of the value as being the same.  */
     583              : 
     584              : class conjured_purge
     585              : {
     586              : public:
     587        39150 :   conjured_purge (region_model *model, region_model_context *ctxt)
     588        39054 :   : m_model (model), m_ctxt (ctxt)
     589              :   {
     590              :   }
     591              :   void purge (const symbolic::conjured_bit_vector &bv) const;
     592              :   void purge (const symbolic::conjured_bit_contents &bc) const;
     593              : 
     594              : private:
     595              :   region_model *m_model;
     596              :   region_model_context *m_ctxt;
     597              : };
     598              : 
     599              : #if CHECKING_P
     600              : 
     601              : namespace selftest {
     602              : 
     603              : /* Implementation detail of ASSERT_SYMBOLIC_NODE_DUMP_EQ.  */
     604              : 
     605              : void
     606              : assert_symbolic_node_dump_eq (const ::selftest::location &loc,
     607              :                               const symbolic::node &node,
     608              :                               const char *expected_str);
     609              : 
     610              : /* Assert that dumping NODE results in EXPECTED_STR.  */
     611              : 
     612              : #define ASSERT_SYMBOLIC_NODE_DUMP_EQ(NODE, EXPECTED_STR) \
     613              :   SELFTEST_BEGIN_STMT                                           \
     614              :   assert_symbolic_node_dump_eq (SELFTEST_LOCATION, NODE,        \
     615              :                                 EXPECTED_STR);                  \
     616              :   SELFTEST_END_STMT
     617              : 
     618              : /* Implementation details of ASSERT_SAME_SYMBOLIC_NODE.  */
     619              : 
     620              : void
     621              : assert_same_symbolic_node (const ::selftest::location &loc,
     622              :                            const char *desc_lhs,
     623              :                            const char *desc_rhs,
     624              :                            const symbolic::node *lhs,
     625              :                            const symbolic::node *rhs);
     626              : 
     627              : inline void
     628         2896 : assert_same_symbolic_node (const ::selftest::location &loc,
     629              :                            const char *desc_lhs,
     630              :                            const char *desc_rhs,
     631              :                            const symbolic::node &lhs,
     632              :                            const symbolic::node &rhs)
     633              : {
     634         2876 :   assert_same_symbolic_node (loc,
     635              :                              desc_lhs,
     636              :                              desc_rhs,
     637              :                              &lhs,
     638              :                              &rhs);
     639              : }
     640              : 
     641              : /* Assert that LHS and RHS are the same symbolic::node instance.  */
     642              : 
     643              : #define ASSERT_SAME_SYMBOLIC_NODE(LHS, RHS)                             \
     644              :   SELFTEST_BEGIN_STMT                                           \
     645              :   assert_same_symbolic_node (SELFTEST_LOCATION, (#LHS), (#RHS), (LHS), (RHS));  \
     646              :   SELFTEST_END_STMT
     647              : 
     648              : #define ASSERT_SAME_SYMBOLIC_NODE_AT(LOC, LHS, RHS)                     \
     649              :   SELFTEST_BEGIN_STMT                                           \
     650              :   assert_same_symbolic_node ((LOC), (#LHS), (#RHS), (LHS), (RHS));      \
     651              :   SELFTEST_END_STMT
     652              : 
     653              : /* Implementation details of ASSERT_DIFFERENT_SYMBOLIC_NODE.  */
     654              : 
     655              : void
     656              : assert_different_symbolic_node (const ::selftest::location &loc,
     657              :                                 const char *desc_lhs,
     658              :                                 const char *desc_rhs,
     659              :                                 const symbolic::node *lhs,
     660              :                                 const symbolic::node *rhs);
     661              : 
     662              : inline void
     663           52 : assert_different_symbolic_node (const ::selftest::location &loc,
     664              :                                 const char *desc_lhs,
     665              :                                 const char *desc_rhs,
     666              :                                 const symbolic::node &lhs,
     667              :                                 const symbolic::node &rhs)
     668              : {
     669           52 :   assert_different_symbolic_node (loc,
     670              :                                   desc_lhs,
     671              :                                   desc_rhs,
     672              :                                   &lhs,
     673              :                                   &rhs);
     674              : }
     675              : 
     676              : /* Assert that LHS and RHS are different symbolic::node instances.  */
     677              : 
     678              : #define ASSERT_DIFFERENT_SYMBOLIC_NODE(LHS, RHS)                                \
     679              :   SELFTEST_BEGIN_STMT                                           \
     680              :   assert_different_symbolic_node (SELFTEST_LOCATION, (#LHS), (#RHS), (LHS), (RHS));     \
     681              :   SELFTEST_END_STMT
     682              : 
     683              : /* Implementation detail of ASSERT_SYMBOLIC_NODE_MARKUP_TEXT_EQ.  */
     684              : 
     685              : void
     686              : assert_symbolic_node_markup_text_eq (const ::selftest::location &loc,
     687              :                                      const symbolic::node &node,
     688              :                                      const diagnostics::markup::lowering_options &,
     689              :                                      const char *expected_str);
     690              : 
     691              : /* Assert that NODE's make_markup_node's result when lowered to plain
     692              :    text is EXPECTED_STR.  */
     693              : 
     694              : #define ASSERT_SYMBOLIC_NODE_MARKUP_TEXT_EQ(NODE, LOWERING_OPTS, EXPECTED_STR) \
     695              :   SELFTEST_BEGIN_STMT                                                   \
     696              :   assert_symbolic_node_markup_text_eq (SELFTEST_LOCATION, (NODE),               \
     697              :                                 (LOWERING_OPTS), (EXPECTED_STR));       \
     698              :   SELFTEST_END_STMT
     699              : 
     700              : } // namespace ana::selftest
     701              : 
     702              : #endif /* CHECKING_P */
     703              : 
     704              : } // namespace ana
     705              : 
     706              : #endif /* GCC_ANALYZER_SYMBOLIC_NODES_H */
        

Generated by: LCOV version 2.5.0-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.