From de2acaa079cbf6bcb1db8fecd956789360d9dd5c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 15 Nov 2010 12:34:44 +0200 Subject: Maintain GCC tree node for all semantic graph nodes --- odb/parser.cxx | 29 ++++++++++++---------- odb/semantics/class-template.cxx | 6 ++--- odb/semantics/class-template.hxx | 2 +- odb/semantics/class.cxx | 2 +- odb/semantics/derived.cxx | 14 +++-------- odb/semantics/derived.hxx | 3 --- odb/semantics/elements.cxx | 4 +-- odb/semantics/elements.hxx | 44 ++++++++++++--------------------- odb/semantics/enum.cxx | 6 ++--- odb/semantics/enum.hxx | 2 +- odb/semantics/fundamental.cxx | 6 ----- odb/semantics/fundamental.hxx | 53 +++++++++++++--------------------------- odb/semantics/namespace.cxx | 4 +-- odb/semantics/namespace.hxx | 6 +++-- odb/semantics/union-template.cxx | 6 ++--- odb/semantics/union-template.hxx | 2 +- odb/semantics/union.cxx | 2 +- odb/semantics/unit.cxx | 4 ++- 18 files changed, 77 insertions(+), 118 deletions(-) diff --git a/odb/parser.cxx b/odb/parser.cxx index 528b55b..0598444 100644 --- a/odb/parser.cxx +++ b/odb/parser.cxx @@ -408,7 +408,7 @@ emit_class (tree c, path const& file, size_t line, size_t clmn, bool stub) type& type_node (emit_type (t, file, line, clmn)); data_member& member_node ( - unit_->new_node (file, line, clmn)); + unit_->new_node (file, line, clmn, d)); unit_->new_edge (*c_node, member_node, name, a); belongs& edge (unit_->new_edge (member_node, type_node)); @@ -561,7 +561,7 @@ emit_union (tree u, path const& file, size_t line, size_t clmn, bool stub) type& type_node (emit_type (t, file, line, clmn)); data_member& member_node ( - unit_->new_node (file, line, clmn)); + unit_->new_node (file, line, clmn, d)); unit_->new_edge (*u_node, member_node, name, a); belongs& edge (unit_->new_edge (member_node, type_node)); @@ -772,9 +772,14 @@ emit () << DECL_SOURCE_LINE (decl) << endl; // Use the declarations's file, line, and column as an - // approximation for this namespace origin. + // approximation for this namespace origin. Also resolve + // the tree node for this namespace. // - namespace_& node (unit_->new_node (f, l, c)); + namespace_& node ( + unit_->new_node ( + f, l, c, + namespace_binding ( + get_identifier (n.c_str ()), scope_->tree_node ()))); unit_->new_edge (*scope_, node, n); scope_ = &node; @@ -1034,6 +1039,7 @@ emit_class_template (tree t, bool stub) // See if there is a stub already for this template. // class_template* ct_node (0); + tree c (TREE_TYPE (DECL_TEMPLATE_RESULT (t))); if (node* n = unit_->find (t)) { @@ -1042,15 +1048,13 @@ emit_class_template (tree t, bool stub) else { path f (DECL_SOURCE_FILE (t)); - size_t l (DECL_SOURCE_LINE (t)); - size_t c (DECL_SOURCE_COLUMN (t)); + size_t ln (DECL_SOURCE_LINE (t)); + size_t cl (DECL_SOURCE_COLUMN (t)); - ct_node = &unit_->new_node (f, l, c); + ct_node = &unit_->new_node (f, ln, cl, c); unit_->insert (t, *ct_node); } - tree c (TREE_TYPE (DECL_TEMPLATE_RESULT (t))); - if (stub || !COMPLETE_TYPE_P (c)) return *ct_node; @@ -1118,6 +1122,7 @@ emit_union_template (tree t, bool stub) // See if there is a stub already for this template. // union_template* ut_node (0); + tree u (TREE_TYPE (DECL_TEMPLATE_RESULT (t))); if (node* n = unit_->find (t)) { @@ -1129,12 +1134,10 @@ emit_union_template (tree t, bool stub) size_t l (DECL_SOURCE_LINE (t)); size_t c (DECL_SOURCE_COLUMN (t)); - ut_node = &unit_->new_node (f, l, c); + ut_node = &unit_->new_node (f, l, c, u); unit_->insert (t, *ut_node); } - tree u (TREE_TYPE (DECL_TEMPLATE_RESULT (t))); - if (stub || !COMPLETE_TYPE_P (u)) return *ut_node; @@ -1227,7 +1230,7 @@ emit_enum (tree e, path const& file, size_t line, size_t clmn, bool stub) // There doesn't seem to be a way to get the proper position for // each enumerator. // - enumerator& er_node = unit_->new_node (file, line, clmn); + enumerator& er_node = unit_->new_node (file, line, clmn, er); unit_->new_edge (*e_node, er_node); if (trace) diff --git a/odb/semantics/class-template.cxx b/odb/semantics/class-template.cxx index ddaf012..0bd3413 100644 --- a/odb/semantics/class-template.cxx +++ b/odb/semantics/class-template.cxx @@ -9,8 +9,8 @@ namespace semantics { class_template:: - class_template (path const& file, size_t line, size_t column) - : node (file, line, column) + class_template (path const& file, size_t line, size_t column, tree tn) + : node (file, line, column, tn) { } @@ -19,7 +19,7 @@ namespace semantics size_t line, size_t column, tree tn) - : node (file, line, column), type (tn) + : node (file, line, column, tn) { } diff --git a/odb/semantics/class-template.hxx b/odb/semantics/class-template.hxx index 699b617..33f148d 100644 --- a/odb/semantics/class-template.hxx +++ b/odb/semantics/class-template.hxx @@ -33,7 +33,7 @@ namespace semantics } public: - class_template (path const&, size_t line, size_t column); + class_template (path const&, size_t line, size_t column, tree); void add_edge_left (inherits& e) diff --git a/odb/semantics/class.cxx b/odb/semantics/class.cxx index c1f494a..47cf438 100644 --- a/odb/semantics/class.cxx +++ b/odb/semantics/class.cxx @@ -16,7 +16,7 @@ namespace semantics class_:: class_ (path const& file, size_t line, size_t column, tree tn) - : node (file, line, column), type (tn) + : node (file, line, column, tn) { } diff --git a/odb/semantics/derived.cxx b/odb/semantics/derived.cxx index 904ffdd..df25c98 100644 --- a/odb/semantics/derived.cxx +++ b/odb/semantics/derived.cxx @@ -8,12 +8,6 @@ namespace semantics { - derived_type:: - derived_type (tree tn) - : type (tn) - { - } - qualifies:: qualifies () { @@ -27,7 +21,7 @@ namespace semantics bool c, bool v, bool r) - : node (file, line, column), derived_type (tn), c_ (c), v_ (v), r_ (r) + : node (file, line, column, tn), c_ (c), v_ (v), r_ (r) { } @@ -38,7 +32,7 @@ namespace semantics pointer:: pointer (path const& file, size_t line, size_t column, tree tn) - : node (file, line, column), derived_type (tn) + : node (file, line, column, tn) { } @@ -49,7 +43,7 @@ namespace semantics reference:: reference (path const& file, size_t line, size_t column, tree tn) - : node (file, line, column), derived_type (tn) + : node (file, line, column, tn) { } @@ -64,7 +58,7 @@ namespace semantics size_t column, tree tn, unsigned long long size) - : node (file, line, column), derived_type (tn), size_ (size) + : node (file, line, column, tn), size_ (size) { } diff --git a/odb/semantics/derived.hxx b/odb/semantics/derived.hxx index 90b7e3c..db9b201 100644 --- a/odb/semantics/derived.hxx +++ b/odb/semantics/derived.hxx @@ -19,9 +19,6 @@ namespace semantics public: virtual type& base_type () const = 0; - - protected: - derived_type (tree); }; // diff --git a/odb/semantics/elements.cxx b/odb/semantics/elements.cxx index 8e62535..728b1b5 100644 --- a/odb/semantics/elements.cxx +++ b/odb/semantics/elements.cxx @@ -21,8 +21,8 @@ namespace semantics // // node:: - node (path const& file, size_t line, size_t column) - : file_ (file), line_ (line), column_ (column) + node (path const& file, size_t line, size_t column, tree tn) + : tree_node_ (tn), file_ (file), line_ (line), column_ (column) { } diff --git a/odb/semantics/elements.hxx b/odb/semantics/elements.hxx index f5d4954..2e8908e 100644 --- a/odb/semantics/elements.hxx +++ b/odb/semantics/elements.hxx @@ -93,6 +93,13 @@ namespace semantics ~node () {} public: + tree + tree_node () const + { + return tree_node_; + } + + public: path const& file () const { @@ -120,7 +127,7 @@ namespace semantics } public: - node (path const& file, size_t line, size_t column); + node (path const& file, size_t line, size_t column, tree); // Sink functions that allow extensions in the form of one-way // edges. @@ -136,6 +143,8 @@ namespace semantics node (); private: + tree tree_node_; + path file_; size_t line_; size_t column_; @@ -388,8 +397,8 @@ namespace semantics find (names&); public: - scope (path const& file, size_t line, size_t column) - : node (file, line, column) + scope (path const& file, size_t line, size_t column, tree tn) + : node (file, line, column, tn) { } @@ -419,13 +428,6 @@ namespace semantics typedef std::vector qualified; public: - tree - tree_node () const - { - return tree_node_; - } - - public: typedef pointer_iterator qualified_iterator; qualified_iterator @@ -454,23 +456,7 @@ namespace semantics using nameable::add_edge_right; - protected: - type (tree tn) - : tree_node_ (tn) - { - } - - // For virtual inheritance. Should never be actually called. - // - type () - { - // GCC plugin machinery #define's abort as a macro. - // - abort (); - } - private: - tree tree_node_; qualified qualified_; }; @@ -574,8 +560,8 @@ namespace semantics class data_member: public nameable, public instance { public: - data_member (path const& file, size_t line, size_t column) - : node (file, line, column) + data_member (path const& file, size_t line, size_t column, tree tn) + : node (file, line, column, tn) { } }; @@ -597,7 +583,7 @@ namespace semantics size_t column, tree tn, string const& type_name) - : node (file, line, column), type (tn), type_name_ (type_name) + : node (file, line, column, tn), type_name_ (type_name) { } diff --git a/odb/semantics/enum.cxx b/odb/semantics/enum.cxx index 9d28c1d..fce67f8 100644 --- a/odb/semantics/enum.cxx +++ b/odb/semantics/enum.cxx @@ -14,14 +14,14 @@ namespace semantics } enumerator:: - enumerator (path const& file, size_t line, size_t column) - : node (file, line, column) + enumerator (path const& file, size_t line, size_t column, tree tn) + : node (file, line, column, tn) { } enum_:: enum_ (path const& file, size_t line, size_t column, tree tn) - : node (file, line, column), type (tn) + : node (file, line, column, tn) { } diff --git a/odb/semantics/enum.hxx b/odb/semantics/enum.hxx index 24fb860..7f124a8 100644 --- a/odb/semantics/enum.hxx +++ b/odb/semantics/enum.hxx @@ -72,7 +72,7 @@ namespace semantics } public: - enumerator (path const&, size_t line, size_t column); + enumerator (path const&, size_t line, size_t column, tree); void add_edge_right (enumerates& e) diff --git a/odb/semantics/fundamental.cxx b/odb/semantics/fundamental.cxx index 087a08f..232cd2a 100644 --- a/odb/semantics/fundamental.cxx +++ b/odb/semantics/fundamental.cxx @@ -8,12 +8,6 @@ namespace semantics { - fund_type:: - fund_type (tree tn) - : type (tn) - { - } - string fund_type:: fq_name () const { diff --git a/odb/semantics/fundamental.hxx b/odb/semantics/fundamental.hxx index 70c6162..3ac3551 100644 --- a/odb/semantics/fundamental.hxx +++ b/odb/semantics/fundamental.hxx @@ -21,21 +21,16 @@ namespace semantics virtual string fq_name (names*) const; - - protected: - fund_type (tree tn); }; struct fund_void: fund_type { - fund_void (tree tn) - : node (path (""), 0, 0), fund_type (tn) {} + fund_void (tree tn): node (path (""), 0, 0, tn) {} }; struct fund_bool: fund_type { - fund_bool (tree tn) - : node (path (""), 0, 0), fund_type (tn) {} + fund_bool (tree tn): node (path (""), 0, 0, tn) {} }; // @@ -44,74 +39,63 @@ namespace semantics struct fund_char: fund_type { - fund_char (tree tn) - : node (path (""), 0, 0), fund_type (tn) {} + fund_char (tree tn): node (path (""), 0, 0, tn) {} }; struct fund_wchar: fund_type { - fund_wchar (tree tn) - : node (path (""), 0, 0), fund_type (tn) {} + fund_wchar (tree tn): node (path (""), 0, 0, tn) {} }; struct fund_signed_char: fund_type { - fund_signed_char (tree tn) - : node (path (""), 0, 0), fund_type (tn) {} + fund_signed_char (tree tn): node (path (""), 0, 0, tn) {} }; struct fund_unsigned_char: fund_type { - fund_unsigned_char (tree tn) - : node (path (""), 0, 0), fund_type (tn) {} + fund_unsigned_char (tree tn): node (path (""), 0, 0, tn) {} }; struct fund_short: fund_type { - fund_short (tree tn) - : node (path (""), 0, 0), fund_type (tn) {} + fund_short (tree tn): node (path (""), 0, 0, tn) {} }; struct fund_unsigned_short: fund_type { - fund_unsigned_short (tree tn) - : node (path (""), 0, 0), fund_type (tn) {} + fund_unsigned_short (tree tn): node (path (""), 0, 0, tn) {} }; struct fund_int: fund_type { - fund_int (tree tn) - : node (path (""), 0, 0), fund_type (tn) {} + fund_int (tree tn): node (path (""), 0, 0, tn) {} }; struct fund_unsigned_int: fund_type { - fund_unsigned_int (tree tn) - : node (path (""), 0, 0), fund_type (tn) {} + fund_unsigned_int (tree tn): node (path (""), 0, 0, tn) {} }; struct fund_long: fund_type { - fund_long (tree tn) - : node (path (""), 0, 0), fund_type (tn) {} + fund_long (tree tn): node (path (""), 0, 0, tn) {} }; struct fund_unsigned_long: fund_type { - fund_unsigned_long (tree tn) - : node (path (""), 0, 0), fund_type (tn) {} + fund_unsigned_long (tree tn): node (path (""), 0, 0, tn) {} }; struct fund_long_long: fund_type { - fund_long_long (tree tn) - : node (path (""), 0, 0), fund_type (tn) {} + fund_long_long (tree tn): node (path (""), 0, 0, tn) {} }; struct fund_unsigned_long_long: fund_type { fund_unsigned_long_long (tree tn) - : node (path (""), 0, 0), fund_type (tn) {} + : node (path (""), 0, 0, tn) {} }; // @@ -120,20 +104,17 @@ namespace semantics struct fund_float: fund_type { - fund_float (tree tn) - : node (path (""), 0, 0), fund_type (tn) {} + fund_float (tree tn): node (path (""), 0, 0, tn) {} }; struct fund_double: fund_type { - fund_double (tree tn) - : node (path (""), 0, 0), fund_type (tn) {} + fund_double (tree tn): node (path (""), 0, 0, tn) {} }; struct fund_long_double: fund_type { - fund_long_double (tree tn) - : node (path (""), 0, 0), fund_type (tn) {} + fund_long_double (tree tn): node (path (""), 0, 0, tn) {} }; } diff --git a/odb/semantics/namespace.cxx b/odb/semantics/namespace.cxx index a0a9246..b873b79 100644 --- a/odb/semantics/namespace.cxx +++ b/odb/semantics/namespace.cxx @@ -9,8 +9,8 @@ namespace semantics { namespace_:: - namespace_ (path const& file, size_t line, size_t column) - : node (file, line, column) + namespace_ (path const& file, size_t line, size_t column, tree tn) + : node (file, line, column, tn) { } diff --git a/odb/semantics/namespace.hxx b/odb/semantics/namespace.hxx index 105ed0b..ea09228 100644 --- a/odb/semantics/namespace.hxx +++ b/odb/semantics/namespace.hxx @@ -13,12 +13,14 @@ namespace semantics class namespace_: public scope { public: - namespace_ (path const&, size_t line, size_t column); - namespace_ (); + namespace_ (path const&, size_t line, size_t column, tree); // Resolve conflict between scope::scope and nameable::scope. // using nameable::scope; + + protected: + namespace_ (); }; } diff --git a/odb/semantics/union-template.cxx b/odb/semantics/union-template.cxx index c0ab198..ae95c60 100644 --- a/odb/semantics/union-template.cxx +++ b/odb/semantics/union-template.cxx @@ -9,8 +9,8 @@ namespace semantics { union_template:: - union_template (path const& file, size_t line, size_t column) - : node (file, line, column) + union_template (path const& file, size_t line, size_t column, tree tn) + : node (file, line, column, tn) { } @@ -19,7 +19,7 @@ namespace semantics size_t line, size_t column, tree tn) - : node (file, line, column), type (tn) + : node (file, line, column, tn) { } diff --git a/odb/semantics/union-template.hxx b/odb/semantics/union-template.hxx index 54bf447..49b820e 100644 --- a/odb/semantics/union-template.hxx +++ b/odb/semantics/union-template.hxx @@ -15,7 +15,7 @@ namespace semantics class union_template: public type_template, public scope { public: - union_template (path const&, size_t line, size_t column); + union_template (path const&, size_t line, size_t column, tree); // Resolve conflict between scope::scope and nameable::scope. // diff --git a/odb/semantics/union.cxx b/odb/semantics/union.cxx index 5acc21f..7eb6fbd 100644 --- a/odb/semantics/union.cxx +++ b/odb/semantics/union.cxx @@ -10,7 +10,7 @@ namespace semantics { union_:: union_ (path const& file, size_t line, size_t column, tree tn) - : node (file, line, column), type (tn) + : node (file, line, column, tn) { } diff --git a/odb/semantics/unit.cxx b/odb/semantics/unit.cxx index 3540e15..56d4f87 100644 --- a/odb/semantics/unit.cxx +++ b/odb/semantics/unit.cxx @@ -3,6 +3,8 @@ // copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC // license : GNU GPL v3; see accompanying LICENSE file +#include + #include #include @@ -10,7 +12,7 @@ namespace semantics { unit:: unit (path const& file) - : node (file, 1, 1), graph_ (*this) + : node (file, 1, 1, global_namespace), graph_ (*this) { // Use a special edge to get this->name() return the global // namespace name (""). -- cgit v1.1