summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-03-29 11:40:32 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-03-29 11:40:32 +0200
commit16692f69f3ce5e533c835b553bd00e149191fd9c (patch)
tree1c0a0b6f45499aae413401c1f377ba7b4ef1cdab
parent02900cdf9a156e631b16c4360c8cb7e6484b004f (diff)
Assign tree nodes to graph type nodes
-rw-r--r--odb/plugin.cxx45
-rw-r--r--odb/semantics/class-template.hxx7
-rw-r--r--odb/semantics/class.hxx4
-rw-r--r--odb/semantics/derived.hxx28
-rw-r--r--odb/semantics/elements.hxx30
-rw-r--r--odb/semantics/enum.hxx4
-rw-r--r--odb/semantics/fundamental.hxx58
-rw-r--r--odb/semantics/union-template.hxx7
-rw-r--r--odb/semantics/union.hxx4
-rw-r--r--odb/semantics/unit.hxx20
10 files changed, 128 insertions, 79 deletions
diff --git a/odb/plugin.cxx b/odb/plugin.cxx
index 15350f3..35e6ab6 100644
--- a/odb/plugin.cxx
+++ b/odb/plugin.cxx
@@ -261,9 +261,10 @@ private:
//
if (TYPE_PTRMEMFUNC_P (t))
{
+ t = TYPE_MAIN_VARIANT (t);
node = &unit_->new_node<unsupported_type> (
- file, line, clmn, "pointer_to_member_function_type");
- unit_->insert (TYPE_MAIN_VARIANT (t), *node);
+ file, line, clmn, t, "pointer_to_member_function_type");
+ unit_->insert (t, *node);
}
else
{
@@ -558,7 +559,7 @@ private:
}
else
{
- c_node = &unit_->new_node<T> (file, line, clmn);
+ c_node = &unit_->new_node<T> (file, line, clmn, c);
unit_->insert (c, *c_node);
}
@@ -747,7 +748,7 @@ private:
}
else
{
- u_node = &unit_->new_node<T> (file, line, clmn);
+ u_node = &unit_->new_node<T> (file, line, clmn, u);
unit_->insert (u, *u_node);
}
@@ -859,7 +860,7 @@ private:
}
else
{
- e_node = &unit_->new_node<enum_> (file, line, clmn);
+ e_node = &unit_->new_node<enum_> (file, line, clmn, e);
unit_->insert (e, *e_node);
}
@@ -936,9 +937,10 @@ private:
}
}
- // No such variant yet. Create a new one.
+ // No such variant yet. Create a new one. Qualified types are not
+ // unique in the tree so don't add this node to the map.
//
- qualifier& q (unit_->new_node<qualifier> (file, line, clmn, qc, qv, qr));
+ qualifier& q (unit_->new_node<qualifier> (file, line, clmn, t, qc, qv, qr));
unit_->new_edge<qualifies> (q, r);
return q;
}
@@ -983,7 +985,7 @@ private:
if (TYPE_PTRMEMFUNC_P (t))
{
r = &unit_->new_node<unsupported_type> (
- file, line, clmn, "pointer_to_member_function_type");
+ file, line, clmn, t, "pointer_to_member_function_type");
unit_->insert (t, *r);
}
else
@@ -1154,18 +1156,20 @@ private:
}
type& bt (emit_type (TREE_TYPE (t), file, line, clmn));
- array& a (unit_->new_node<array> (file, line, clmn, size));
+ t = TYPE_MAIN_VARIANT (t);
+ array& a (unit_->new_node<array> (file, line, clmn, t, size));
+ unit_->insert (t, a);
unit_->new_edge<contains> (a, bt);
- unit_->insert (TYPE_MAIN_VARIANT (t), a);
r = &a;
break;
}
case REFERENCE_TYPE:
{
type& bt (emit_type (TREE_TYPE (t), file, line, clmn));
- reference& ref (unit_->new_node<reference> (file, line, clmn));
+ t = TYPE_MAIN_VARIANT (t);
+ reference& ref (unit_->new_node<reference> (file, line, clmn, t));
+ unit_->insert (t, ref);
unit_->new_edge<references> (ref, bt);
- unit_->insert (TYPE_MAIN_VARIANT (t), ref);
r = &ref;
break;
}
@@ -1174,16 +1178,18 @@ private:
if (!TYPE_PTRMEM_P (t))
{
type& bt (emit_type (TREE_TYPE (t), file, line, clmn));
- pointer& p (unit_->new_node<pointer> (file, line, clmn));
+ t = TYPE_MAIN_VARIANT (t);
+ pointer& p (unit_->new_node<pointer> (file, line, clmn, t));
+ unit_->insert (t, p);
unit_->new_edge<points> (p, bt);
- unit_->insert (TYPE_MAIN_VARIANT (t), p);
r = &p;
}
else
{
+ t = TYPE_MAIN_VARIANT (t);
r = &unit_->new_node<unsupported_type> (
- file, line, clmn, "pointer_to_data_member_type");
- unit_->insert (TYPE_MAIN_VARIANT (t), *r);
+ file, line, clmn, t, "pointer_to_data_member_type");
+ unit_->insert (t, *r);
if (trace)
ts << "unsupported pointer_to_data_member_type (" << r << ")"
@@ -1193,9 +1199,10 @@ private:
}
default:
{
+ t = TYPE_MAIN_VARIANT (t);
r = &unit_->new_node<unsupported_type> (
- file, line, clmn, tree_code_name[tc]);
- unit_->insert (TYPE_MAIN_VARIANT (t), *r);
+ file, line, clmn, t, tree_code_name[tc]);
+ unit_->insert (t, *r);
if (trace)
ts << "unsupported " << tree_code_name[tc] << " (" << r << ")"
@@ -1441,7 +1448,7 @@ private:
t = TYPE_MAIN_VARIANT (t);
char const* name (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (t))));
- T& node (unit_->new_fund_node<T> ());
+ T& node (unit_->new_fund_node<T> (t));
unit_->new_edge<defines> (*scope_, node, name);
unit_->insert (t, node);
}
diff --git a/odb/semantics/class-template.hxx b/odb/semantics/class-template.hxx
index 6443a19..68a6151 100644
--- a/odb/semantics/class-template.hxx
+++ b/odb/semantics/class-template.hxx
@@ -63,8 +63,11 @@ namespace semantics
class class_instantiation: public class_, public type_instantiation
{
public:
- class_instantiation (path const& file, size_t line, size_t column)
- : node (file, line, column)
+ class_instantiation (path const& file,
+ size_t line,
+ size_t column,
+ tree tn)
+ : node (file, line, column), type (tn)
{
}
diff --git a/odb/semantics/class.hxx b/odb/semantics/class.hxx
index bbe4687..348fbdf 100644
--- a/odb/semantics/class.hxx
+++ b/odb/semantics/class.hxx
@@ -91,8 +91,8 @@ namespace semantics
}
public:
- class_ (path const& file, size_t line, size_t column)
- : node (file, line, column)
+ class_ (path const& file, size_t line, size_t column, tree tn)
+ : node (file, line, column), type (tn)
{
}
diff --git a/odb/semantics/derived.hxx b/odb/semantics/derived.hxx
index 01dd79c..00ab18a 100644
--- a/odb/semantics/derived.hxx
+++ b/odb/semantics/derived.hxx
@@ -19,6 +19,12 @@ namespace semantics
public:
virtual type&
base_type () const = 0;
+
+ protected:
+ derived_type (tree tn)
+ : type (tn)
+ {
+ }
};
//
@@ -104,17 +110,17 @@ namespace semantics
qualifier (path const& file,
size_t line,
size_t column,
+ tree tn,
bool c,
bool v,
bool r)
- : node (file, line, column), c_ (c), v_ (v), r_ (r), qualifies_ (0)
+ : node (file, line, column), derived_type (tn), c_ (c), v_ (v), r_ (r)
{
}
void
add_edge_left (qualifies_type& e)
{
- assert (qualifies_ == 0);
qualifies_ = &e;
}
@@ -167,7 +173,7 @@ namespace semantics
pointer_type* pointer_;
};
- class pointer: public type
+ class pointer: public derived_type
{
public:
typedef semantics::points points_type;
@@ -185,15 +191,14 @@ namespace semantics
}
public:
- pointer (path const& file, size_t line, size_t column)
- : node (file, line, column), points_ (0)
+ pointer (path const& file, size_t line, size_t column, tree tn)
+ : node (file, line, column), derived_type (tn)
{
}
void
add_edge_left (points_type& e)
{
- assert (points_ == 0);
points_ = &e;
}
@@ -246,7 +251,7 @@ namespace semantics
reference_type* reference_;
};
- class reference: public type
+ class reference: public derived_type
{
public:
typedef semantics::references references_type;
@@ -264,15 +269,14 @@ namespace semantics
}
public:
- reference (path const& file, size_t line, size_t column)
- : node (file, line, column), references_ (0)
+ reference (path const& file, size_t line, size_t column, tree tn)
+ : node (file, line, column), derived_type (tn)
{
}
void
add_edge_left (references_type& e)
{
- assert (references_ == 0);
references_ = &e;
}
@@ -355,15 +359,15 @@ namespace semantics
array (path const& file,
size_t line,
size_t column,
+ tree tn,
unsigned long long size)
- : node (file, line, column), contains_ (0), size_ (size)
+ : node (file, line, column), derived_type (tn), size_ (size)
{
}
void
add_edge_left (contains_type& e)
{
- assert (contains_ == 0);
contains_ = &e;
}
diff --git a/odb/semantics/elements.hxx b/odb/semantics/elements.hxx
index 97f386f..969f33a 100644
--- a/odb/semantics/elements.hxx
+++ b/odb/semantics/elements.hxx
@@ -36,10 +36,6 @@ namespace semantics
using compiler::context;
- // GCC parse tree node.
- //
- typedef ::tree gcc_tree;
-
//
//
using fs::path;
@@ -422,6 +418,13 @@ namespace semantics
typedef std::vector<qualifies*> qualified;
public:
+ tree
+ tree_node () const
+ {
+ return tree_node_;
+ }
+
+ public:
typedef pointer_iterator<qualified::const_iterator> qualified_iterator;
qualified_iterator
@@ -437,11 +440,6 @@ namespace semantics
}
public:
- type (path const& file, size_t line, size_t column)
- : node (file, line, column)
- {
- }
-
void
add_edge_right (belongs&)
{
@@ -456,11 +454,22 @@ 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_;
};
@@ -570,8 +579,9 @@ namespace semantics
unsupported_type (path const& file,
size_t line,
size_t column,
+ tree tn,
string const& type_name)
- : node (file, line, column), type_name_ (type_name)
+ : node (file, line, column), type (tn), type_name_ (type_name)
{
}
diff --git a/odb/semantics/enum.hxx b/odb/semantics/enum.hxx
index e628ad9..5ef369c 100644
--- a/odb/semantics/enum.hxx
+++ b/odb/semantics/enum.hxx
@@ -114,8 +114,8 @@ namespace semantics
}
public:
- enum_ (path const& file, size_t line, size_t column)
- : node (file, line, column)
+ enum_ (path const& file, size_t line, size_t column, tree tn)
+ : node (file, line, column), type (tn)
{
}
diff --git a/odb/semantics/fundamental.hxx b/odb/semantics/fundamental.hxx
index aa8225a..eea49a8 100644
--- a/odb/semantics/fundamental.hxx
+++ b/odb/semantics/fundamental.hxx
@@ -14,16 +14,23 @@ namespace semantics
// Fundamental C++ types.
//
- class fund_type: public type {};
+ class fund_type: public type
+ {
+ protected:
+ fund_type (tree tn)
+ : type (tn) {}
+ };
struct fund_void: fund_type
{
- fund_void (): node (path ("<fundamental>"), 0, 0) {}
+ fund_void (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_bool: fund_type
{
- fund_bool (): node (path ("<fundamental>"), 0, 0) {}
+ fund_bool (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
//
@@ -32,62 +39,74 @@ namespace semantics
struct fund_char: fund_type
{
- fund_char (): node (path ("<fundamental>"), 0, 0) {}
+ fund_char (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_wchar: fund_type
{
- fund_wchar (): node (path ("<fundamental>"), 0, 0) {}
+ fund_wchar (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_signed_char: fund_type
{
- fund_signed_char (): node (path ("<fundamental>"), 0, 0) {}
+ fund_signed_char (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_unsigned_char: fund_type
{
- fund_unsigned_char (): node (path ("<fundamental>"), 0, 0) {}
+ fund_unsigned_char (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_short: fund_type
{
- fund_short (): node (path ("<fundamental>"), 0, 0) {}
+ fund_short (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_unsigned_short: fund_type
{
- fund_unsigned_short (): node (path ("<fundamental>"), 0, 0) {}
+ fund_unsigned_short (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_int: fund_type
{
- fund_int (): node (path ("<fundamental>"), 0, 0) {}
+ fund_int (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_unsigned_int: fund_type
{
- fund_unsigned_int (): node (path ("<fundamental>"), 0, 0) {}
+ fund_unsigned_int (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_long: fund_type
{
- fund_long (): node (path ("<fundamental>"), 0, 0) {}
+ fund_long (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_unsigned_long: fund_type
{
- fund_unsigned_long (): node (path ("<fundamental>"), 0, 0) {}
+ fund_unsigned_long (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_long_long: fund_type
{
- fund_long_long (): node (path ("<fundamental>"), 0, 0) {}
+ fund_long_long (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_unsigned_long_long: fund_type
{
- fund_unsigned_long_long (): node (path ("<fundamental>"), 0, 0) {}
+ fund_unsigned_long_long (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
//
@@ -96,17 +115,20 @@ namespace semantics
struct fund_float: fund_type
{
- fund_float (): node (path ("<fundamental>"), 0, 0) {}
+ fund_float (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_double: fund_type
{
- fund_double (): node (path ("<fundamental>"), 0, 0) {}
+ fund_double (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_long_double: fund_type
{
- fund_long_double (): node (path ("<fundamental>"), 0, 0) {}
+ fund_long_double (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
}
diff --git a/odb/semantics/union-template.hxx b/odb/semantics/union-template.hxx
index 1aaadb7..8e74e6e 100644
--- a/odb/semantics/union-template.hxx
+++ b/odb/semantics/union-template.hxx
@@ -28,8 +28,11 @@ namespace semantics
class union_instantiation: public union_, public type_instantiation
{
public:
- union_instantiation (path const& file, size_t line, size_t column)
- : node (file, line, column)
+ union_instantiation (path const& file,
+ size_t line,
+ size_t column,
+ tree tn)
+ : node (file, line, column), type (tn)
{
}
diff --git a/odb/semantics/union.hxx b/odb/semantics/union.hxx
index 2873d97..e4b93a9 100644
--- a/odb/semantics/union.hxx
+++ b/odb/semantics/union.hxx
@@ -13,8 +13,8 @@ namespace semantics
class union_: public virtual type, public scope
{
public:
- union_ (path const& file, size_t line, size_t column)
- : node (file, line, column)
+ union_ (path const& file, size_t line, size_t column, tree tn)
+ : node (file, line, column), type (tn)
{
}
diff --git a/odb/semantics/unit.hxx b/odb/semantics/unit.hxx
index c208876..05eec7f 100644
--- a/odb/semantics/unit.hxx
+++ b/odb/semantics/unit.hxx
@@ -25,20 +25,20 @@ namespace semantics
new_edge<global_names> (*this, *this);
}
- // Mapping from GCC tree node to semantic graph node.
+ // Mapping from tree nodes to semantic graph nodes.
//
public:
node*
- find (gcc_tree key) const
+ find (tree key) const
{
- gcc_tree_node_map::const_iterator i (gcc_tree_node_map_.find (key));
- return i != gcc_tree_node_map_.end () ? i->second : 0;
+ tree_node_map::const_iterator i (tree_node_map_.find (key));
+ return i != tree_node_map_.end () ? i->second : 0;
}
void
- insert (gcc_tree key, node& value)
+ insert (tree key, node& value)
{
- gcc_tree_node_map_[key] = &value;
+ tree_node_map_[key] = &value;
}
public:
@@ -84,9 +84,9 @@ namespace semantics
//
template <typename T>
T&
- new_fund_node ()
+ new_fund_node (tree tn)
{
- return graph_.new_node<T> ();
+ return graph_.new_node<T> (tn);
}
protected:
@@ -134,8 +134,8 @@ namespace semantics
private:
graph<node, edge>& graph_;
- typedef std::map<gcc_tree, node*> gcc_tree_node_map;
- gcc_tree_node_map gcc_tree_node_map_;
+ typedef std::map<tree, node*> tree_node_map;
+ tree_node_map tree_node_map_;
};
}