libabigail
Classes | Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
scope_decl Class Reference

A declaration that introduces a scope. More...

#include <abg-ir.h>

Inheritance diagram for scope_decl:
[legend]

Classes

struct  hash
 Hasher for the scope_decl type. More...
 

Public Types

typedef std::vector< decl_base_sptr > declarations
 Convenience typedef for a vector of decl_base_sptr. More...
 
typedef std::vector< function_type_sptrfunction_types
 Convenience typedef for a vector of function_type_sptr. More...
 
typedef std::vector< scope_decl_sptrscopes
 Convenience typedef for a vector of scope_decl_sptr. More...
 
- Public Types inherited from decl_base
enum  binding { BINDING_NONE , BINDING_LOCAL , BINDING_GLOBAL , BINDING_WEAK }
 ELF binding. More...
 
enum  visibility {
  VISIBILITY_NONE , VISIBILITY_DEFAULT , VISIBILITY_PROTECTED , VISIBILITY_HIDDEN ,
  VISIBILITY_INTERNAL
}
 ELF visibility. More...
 

Public Member Functions

 scope_decl (const environment &env, const string &name, const location &locus, visibility vis=VISIBILITY_DEFAULT)
 Constructor of the scope_decl type. More...
 
 scope_decl (const environment &env, location &l)
 Constructor of the scope_decl type. More...
 
void add_member_type (type_base_sptr t)
 Add a member type to the current instance of class_or_union. More...
 
type_base_sptr add_member_type (type_base_sptr t, access_specifier a)
 Add a member type to the current instance of class_or_union. More...
 
bool find_iterator_for_member (const decl_base *, declarations::iterator &)
 Find a member of the current scope and return an iterator on it. More...
 
bool find_iterator_for_member (const decl_base_sptr, declarations::iterator &)
 Find a member of the current scope and return an iterator on it. More...
 
type_base_sptr find_member_type (const string &name) const
 Find a member type of a given name, inside the current scope_decl. More...
 
canonical_type_sptr_set_typeget_canonical_types ()
 @eturn the set of canonical types of the the current scope. More...
 
const canonical_type_sptr_set_typeget_canonical_types () const
 @eturn the set of canonical types of the the current scope. More...
 
virtual size_t get_hash () const
 Return the hash value for the current instance of scope_decl. More...
 
declarationsget_member_decls ()
 Getter for the member declarations carried by the current scope_decl. More...
 
const declarationsget_member_decls () const
 Getter for the member declarations carried by the current scope_decl. More...
 
scopesget_member_scopes ()
 Getter for the scopes carried by the current scope. More...
 
const scopesget_member_scopes () const
 Getter for the scopes carried by the current scope. More...
 
const type_base_sptrs_typeget_member_types () const
 Get the member types of this scope_decl. More...
 
virtual size_t get_num_anonymous_member_classes () const
 Getter for the number of anonymous classes contained in this scope. More...
 
virtual size_t get_num_anonymous_member_enums () const
 Getter for the number of anonymous enums contained in this scope. More...
 
virtual size_t get_num_anonymous_member_unions () const
 Getter for the number of anonymous unions contained in this scope. More...
 
const type_base_sptrs_typeget_sorted_canonical_types () const
 Return a vector of sorted canonical types of the current scope. More...
 
const declarationsget_sorted_member_decls () const
 Getter for the sorted member declarations carried by the current scope_decl. More...
 
const type_base_sptrs_typeget_sorted_member_types () const
 Get the sorted member types of this scope_decl. More...
 
void insert_member_type (type_base_sptr t, declarations::iterator before)
 Insert a member type. More...
 
bool is_empty () const
 Test if the current scope is empty. More...
 
virtual bool operator== (const decl_base &) const
 Return true iff both scopes have the same names and have the same member decls. More...
 
void remove_member_type (type_base_sptr t)
 Remove a member type from the current class_or_union scope. More...
 
virtual bool traverse (ir_node_visitor &)
 This implements the ir_traversable_base::traverse pure virtual function. More...
 
- Public Member Functions inherited from decl_base
 decl_base (const environment &, const location &)
 Constructor for the decl_base type. More...
 
 decl_base (const environment &e, const interned_string &name, const location &locus, const interned_string &mangled_name=interned_string(), visibility vis=VISIBILITY_DEFAULT)
 Constructor. More...
 
 decl_base (const environment &e, const string &name, const location &locus, const string &mangled_name="", visibility vis=VISIBILITY_DEFAULT)
 Constructor for the decl_base type. More...
 
virtual ~decl_base ()
 Destructor of the decl_base type. More...
 
const decl_base_sptr get_definition_of_declaration () const
 If this decl_base is declaration-only, get its definition, if any. More...
 
const decl_base_sptr get_earlier_declaration () const
 If this decl_base is a definition, get its earlier declaration. More...
 
bool get_has_anonymous_parent () const
 Get the "has_anonymous_parent" flag of the current declaration. More...
 
bool get_is_anonymous () const
 Test if the current declaration is anonymous. More...
 
bool get_is_anonymous_or_has_anonymous_parent () const
 
bool get_is_declaration_only () const
 Test if a decl_base is a declaration-only decl. More...
 
bool get_is_in_public_symbol_table () const
 Test if the decl is defined in a ELF symbol table as a public symbol. More...
 
const interned_stringget_linkage_name () const
 Getter for the mangled name. More...
 
const locationget_location () const
 Get the location of a given declaration. More...
 
const decl_baseget_naked_definition_of_declaration () const
 If this decl_base is declaration-only, get its definition, if any. More...
 
const interned_stringget_name () const
 Getter for the name of the current decl. More...
 
typedef_decl_sptr get_naming_typedef () const
 Getter for the naming typedef of the current decl. More...
 
virtual string get_pretty_representation (bool internal=false, bool qualified_name=true) const
 Get the pretty representatin of the current declaration. More...
 
virtual const interned_stringget_qualified_name (bool internal=false) const
 Return the qualified name of the decl. More...
 
virtual void get_qualified_name (interned_string &qualified_name, bool internal=false) const
 Compute the qualified name of the decl. More...
 
const interned_stringget_qualified_parent_name () const
 Return a copy of the qualified name of the parent of the current decl. More...
 
scope_declget_scope () const
 Return the type containing the current decl, if any. More...
 
virtual const interned_stringget_scoped_name () const
 Return the scoped name of the decl. More...
 
visibility get_visibility () const
 Getter for the visibility of the decl. More...
 
virtual bool operator!= (const decl_base &) const
 Inequality operator. More...
 
void set_definition_of_declaration (const decl_base_sptr &)
 Set the definition of this declaration-only decl_base. More...
 
void set_earlier_declaration (const decl_base_sptr &)
 set the earlier declaration of this decl_base definition. More...
 
void set_is_anonymous (bool)
 Set the "is_anonymous" flag of the current declaration. More...
 
void set_is_declaration_only (bool f)
 Set a flag saying if the enum_type_decl is a declaration-only enum_type_decl. More...
 
void set_is_in_public_symbol_table (bool)
 Set the flag saying if this decl is from a symbol that is in a public symbols table, defined as public (global or weak). More...
 
virtual void set_linkage_name (const string &m)
 Setter for the linkage name. More...
 
void set_location (const location &l)
 Set the location for a given declaration. More...
 
void set_name (const string &n)
 Setter for the name of the decl. More...
 
void set_naming_typedef (const typedef_decl_sptr &)
 Set the naming typedef of the current instance of decl_base. More...
 
virtual void set_scope (scope_decl *)
 Setter of the scope of the current decl. More...
 
void set_visibility (visibility v)
 Setter for the visibility of the decl. More...
 
- Public Member Functions inherited from type_or_decl_base
 type_or_decl_base (const environment &, enum type_or_decl_kind k=ABSTRACT_TYPE_OR_DECL)
 Constructor of type_or_decl_base. More...
 
virtual ~type_or_decl_base ()
 The destructor of the type_or_decl_base type. More...
 
locationget_artificial_location () const
 Getter of the artificial location of the artifact. More...
 
corpusget_corpus ()
 Get the corpus this ABI artifact belongs to. More...
 
const corpusget_corpus () const
 Get the corpus this ABI artifact belongs to. More...
 
const environmentget_environment () const
 Getter of the environment of the current ABI artifact. More...
 
bool get_is_artificial () const
 Getter of the flag that says if the artefact is artificial. More...
 
translation_unitget_translation_unit ()
 Get the translation_unit this ABI artifact belongs to. More...
 
const translation_unitget_translation_unit () const
 Get the translation_unit this ABI artifact belongs to. More...
 
bool has_artificial_location () const
 Test if the current ABI artifact carries an artificial location. More...
 
void set_artificial_location (const location &)
 Setter of the artificial location of the artificat. More...
 
void set_is_artificial (bool)
 Setter of the flag that says if the artefact is artificial. More...
 
void set_translation_unit (translation_unit *)
 Set the translation_unit this ABI artifact belongs to. More...
 
- Public Member Functions inherited from traversable_base
virtual ~traversable_base ()
 Destructor of the traversable_base type. More...
 

Protected Member Functions

virtual decl_base_sptr add_member_decl (const decl_base_sptr &member)
 Add a member decl to this scope. Note that user code should not use this, but rather use add_decl_to_scope. More...
 
decl_base_sptr insert_member_decl (decl_base_sptr member, declarations::iterator before)
 Insert a member decl to this scope, right before an element pointed to by a given iterator. Note that user code should not use this, but rather use insert_decl_into_scope. More...
 
virtual void remove_member_decl (decl_base_sptr member)
 Remove a declaration from the current scope. More...
 
- Protected Member Functions inherited from decl_base
 decl_base (const decl_base &)
 
void clear_qualified_name ()
 Clear the qualified name of this decl. More...
 
context_relget_context_rel ()
 Getter for the context relationship. More...
 
const context_relget_context_rel () const
 Getter for the context relationship. More...
 
const interned_stringpeek_qualified_name () const
 Getter for the qualified name. More...
 
const interned_stringpeek_temporary_qualified_name () const
 Getter of the temporary qualified name of the current declaration. More...
 
void set_context_rel (context_rel *c)
 
void set_qualified_name (const interned_string &) const
 Setter for the qualified name. More...
 
void set_temporary_qualified_name (const interned_string &) const
 Setter for the temporary qualified name of the current declaration. More...
 
- Protected Member Functions inherited from type_or_decl_base
bool hashing_started () const
 Getter for the 'hashing_started' property. More...
 
void hashing_started (bool) const
 Setter for the 'hashing_started' property. More...
 
enum type_or_decl_kind kind () const
 Getter for the "kind" property of type_or_decl_base type. More...
 
void kind (enum type_or_decl_kind)
 Setter for the "kind" property of type_or_decl_base type. More...
 
type_or_decl_baseoperator= (const type_or_decl_base &)
 
void * runtime_type_instance ()
 Getter of the pointer to the runtime type sub-object of the current instance. More...
 
const void * runtime_type_instance () const
 Getter of the pointer to the runtime type sub-object of the current instance. More...
 
void runtime_type_instance (void *)
 Setter of the pointer to the runtime type sub-object of the current instance. More...
 
void * type_or_decl_base_pointer ()
 Getter of the pointer to either the type_base sub-object of the current instance if it's a type, or to the decl_base sub-object of the current instance if it's a decl. More...
 
const void * type_or_decl_base_pointer () const
 Getter of the pointer to either the type_base sub-object of the current instance if it's a type, or to the decl_base sub-object of the current instance if it's a decl. More...
 
- Protected Member Functions inherited from traversable_base
 traversable_base ()
 Default constructor of the traversable_base type. More...
 
bool visiting () const
 This should returns false before and after the node has been visiting. During the visiting of the node (and of its children) this should return true. More...
 
void visiting (bool f)
 The traversing code should be responsible of calling this, not the user code. More...
 

Friends

decl_base_sptr add_decl_to_scope (decl_base_sptr decl, scope_decl *scope)
 Appends a declaration to a given scope, if the declaration doesn't already belong to one and if the declaration is not for a type that is supposed to be unique. More...
 
decl_base_sptr insert_decl_into_scope (decl_base_sptr decl, scope_decl::declarations::iterator before, scope_decl *scope)
 Inserts a declaration into a given scope, before a given IR child node of the scope. More...
 
void remove_decl_from_scope (decl_base_sptr decl)
 Remove a given decl from its scope. More...
 

Additional Inherited Members

- Public Attributes inherited from decl_base
priv * priv_
 
- Protected Types inherited from type_or_decl_base
enum  type_or_decl_kind {
  ABSTRACT_TYPE_OR_DECL , ABSTRACT_DECL_BASE , ABSTRACT_SCOPE_DECL , GLOBAL_SCOPE_DECL ,
  NAMESPACE_DECL , VAR_DECL , FUNCTION_DECL , FUNCTION_PARAMETER_DECL ,
  METHOD_DECL , TEMPLATE_DECL , ABSTRACT_TYPE_BASE , ABSTRACT_SCOPE_TYPE_DECL ,
  BASIC_TYPE , SUBRANGE_TYPE , QUALIFIED_TYPE , POINTER_TYPE ,
  REFERENCE_TYPE , POINTER_TO_MEMBER_TYPE , ARRAY_TYPE , ENUM_TYPE ,
  TYPEDEF_TYPE , CLASS_TYPE , UNION_TYPE , FUNCTION_TYPE ,
  METHOD_TYPE
}
 This is a bitmap type which instance is meant to contain the runtime type of a given ABI artifact. Bits of the identifiers of the type of a given artifact as well as the types it inherits from are to be set to 1. More...
 

Detailed Description

A declaration that introduces a scope.

Definition at line 1808 of file abg-ir.h.

Member Typedef Documentation

◆ declarations

typedef std::vector<decl_base_sptr > declarations

Convenience typedef for a vector of decl_base_sptr.

Definition at line 1816 of file abg-ir.h.

◆ function_types

typedef std::vector<function_type_sptr > function_types

Convenience typedef for a vector of function_type_sptr.

Definition at line 1818 of file abg-ir.h.

◆ scopes

typedef std::vector<scope_decl_sptr> scopes

Convenience typedef for a vector of scope_decl_sptr.

Definition at line 1820 of file abg-ir.h.

Constructor & Destructor Documentation

◆ scope_decl() [1/2]

scope_decl ( const environment env,
const string &  name,
const location locus,
visibility  vis = VISIBILITY_DEFAULT 
)

Constructor of the scope_decl type.

Parameters
theenvironment to use for the new instance.
thename of the scope decl.
locusthe source location where the scope_decl is defined.
visthe visibility of the declaration.

Definition at line 8007 of file abg-ir.cc.

◆ scope_decl() [2/2]

scope_decl ( const environment env,
location l 
)

Constructor of the scope_decl type.

Parameters
theenvironment to use for the new instance.
lthe source location where the scope_decl is defined.
visthe visibility of the declaration.

Definition at line 8023 of file abg-ir.cc.

Member Function Documentation

◆ add_member_decl()

decl_base_sptr add_member_decl ( const decl_base_sptr &  member)
protectedvirtual

Add a member decl to this scope. Note that user code should not use this, but rather use add_decl_to_scope.

Note that this function updates the qualified name of the member decl that is added. It also sets the scope of the member. Thus, it ABG_ASSERTs that member should not have its scope set, prior to calling this function.

Parameters
memberthe new member decl to add to this scope.

Reimplemented in class_or_union.

Definition at line 8223 of file abg-ir.cc.

◆ add_member_type() [1/2]

void add_member_type ( type_base_sptr  t)

Add a member type to the current instance of class_or_union.

Parameters
tthe member type to add. It must not have been added to a scope, otherwise this will violate an ABG_ASSERTion.

Definition at line 8290 of file abg-ir.cc.

◆ add_member_type() [2/2]

type_base_sptr add_member_type ( type_base_sptr  t,
access_specifier  a 
)

Add a member type to the current instance of class_or_union.

Parameters
tthe type to be added as a member type to the current instance of class_or_union. An instance of class_or_union::member_type will be created out of t and and added to the the class.
athe access specifier for the member type to be created.

Definition at line 8301 of file abg-ir.cc.

◆ find_iterator_for_member() [1/2]

bool find_iterator_for_member ( const decl_base decl,
declarations::iterator &  i 
)

Find a member of the current scope and return an iterator on it.

Parameters
declthe scope member to find.
ithe iterator to set to the member decl. This is set iff the function returns true.
Returns
true if the member decl was found, false otherwise.

Definition at line 8547 of file abg-ir.cc.

◆ find_iterator_for_member() [2/2]

bool find_iterator_for_member ( const decl_base_sptr  decl,
declarations::iterator &  i 
)

Find a member of the current scope and return an iterator on it.

Parameters
declthe scope member to find.
ithe iterator to set to the member decl. This is set iff the function returns true.
Returns
true if the member decl was found, false otherwise.

Definition at line 8582 of file abg-ir.cc.

◆ find_member_type()

type_base_sptr find_member_type ( const string &  name) const

Find a member type of a given name, inside the current scope_decl.

Parameters
namethe name of the member type to look for.
Returns
a pointer to the type_base that represents the member type of name name, for the current scope.

Definition at line 8260 of file abg-ir.cc.

◆ get_canonical_types() [1/2]

canonical_type_sptr_set_type & get_canonical_types ( )

@eturn the set of canonical types of the the current scope.

Definition at line 8031 of file abg-ir.cc.

◆ get_canonical_types() [2/2]

const canonical_type_sptr_set_type & get_canonical_types ( ) const

@eturn the set of canonical types of the the current scope.

Definition at line 8036 of file abg-ir.cc.

◆ get_hash()

size_t get_hash ( ) const
virtual

Return the hash value for the current instance of scope_decl.

This method can trigger the computing of the hash value, if need be.

Returns
the hash value.

Reimplemented from decl_base.

Reimplemented in class_decl.

Definition at line 8426 of file abg-ir.cc.

◆ get_member_decls() [1/2]

scope_decl::declarations & get_member_decls ( )

Getter for the member declarations carried by the current scope_decl.

Returns
the member declarations carried by the current scope_decl.

Definition at line 8081 of file abg-ir.cc.

◆ get_member_decls() [2/2]

const scope_decl::declarations & get_member_decls ( ) const

Getter for the member declarations carried by the current scope_decl.

Returns
the member declarations carried by the current scope_decl.

Definition at line 8072 of file abg-ir.cc.

◆ get_member_scopes() [1/2]

scope_decl::scopes & get_member_scopes ( )

Getter for the scopes carried by the current scope.

Returns
the scopes carried by the current scope.

Definition at line 8165 of file abg-ir.cc.

◆ get_member_scopes() [2/2]

const scope_decl::scopes & get_member_scopes ( ) const

Getter for the scopes carried by the current scope.

Returns
the scopes carried by the current scope.

Definition at line 8172 of file abg-ir.cc.

◆ get_member_types()

const type_base_sptrs_type & get_member_types ( ) const

Get the member types of this scope_decl.

Returns
a vector of the member types of this ref class_or_union.

Definition at line 8249 of file abg-ir.cc.

◆ get_num_anonymous_member_classes()

size_t get_num_anonymous_member_classes ( ) const
virtual

Getter for the number of anonymous classes contained in this scope.

Returns
the number of anonymous classes contained in this scope.

Reimplemented in class_or_union.

Definition at line 8112 of file abg-ir.cc.

◆ get_num_anonymous_member_enums()

size_t get_num_anonymous_member_enums ( ) const
virtual

Getter for the number of anonymous enums contained in this scope.

Returns
the number of anonymous enums contained in this scope.

Reimplemented in class_or_union.

Definition at line 8148 of file abg-ir.cc.

◆ get_num_anonymous_member_unions()

size_t get_num_anonymous_member_unions ( ) const
virtual

Getter for the number of anonymous unions contained in this scope.

Returns
the number of anonymous unions contained in this scope.

Reimplemented in class_or_union.

Definition at line 8130 of file abg-ir.cc.

◆ get_sorted_canonical_types()

const type_base_sptrs_type & get_sorted_canonical_types ( ) const

Return a vector of sorted canonical types of the current scope.

The types are sorted "almost topologically". That means, they are sorted using the lexicographic order of the string representing the location their definition point. If a type doesn't have a location, then its pretty representation is used.

Returns
a vector of sorted canonical types of the current scope.

Definition at line 8048 of file abg-ir.cc.

◆ get_sorted_member_decls()

const scope_decl::declarations & get_sorted_member_decls ( ) const

Getter for the sorted member declarations carried by the current scope_decl.

Returns
the sorted member declarations carried by the current scope_decl. The declarations are sorted topologically.

Definition at line 8090 of file abg-ir.cc.

◆ get_sorted_member_types()

const type_base_sptrs_type & get_sorted_member_types ( ) const

Get the sorted member types of this scope_decl.

Returns
a vector of the sorted member types of this ref class_or_union.

Definition at line 8334 of file abg-ir.cc.

◆ insert_member_decl()

decl_base_sptr insert_member_decl ( decl_base_sptr  member,
declarations::iterator  before 
)
protected

Insert a member decl to this scope, right before an element pointed to by a given iterator. Note that user code should not use this, but rather use insert_decl_into_scope.

Note that this function updates the qualified name of the inserted member.

Parameters
memberthe new member decl to add to this scope.
beforean interator pointing to the element before which the new member should be inserted.

Definition at line 8361 of file abg-ir.cc.

◆ insert_member_type()

void insert_member_type ( type_base_sptr  t,
declarations::iterator  before 
)

Insert a member type.

Parameters
tthe type to insert in the scope_decl type.
aniterator right before which t has to be inserted.

Definition at line 8274 of file abg-ir.cc.

◆ is_empty()

bool is_empty ( ) const

Test if the current scope is empty.

Returns
true iff the current scope is empty.

Definition at line 8179 of file abg-ir.cc.

◆ operator==()

bool operator== ( const decl_base o) const
virtual

Return true iff both scopes have the same names and have the same member decls.

This function doesn't check for equality of the scopes of its arguments.

Reimplemented from decl_base.

Reimplemented in union_decl, class_decl, class_or_union, class_tdecl, function_tdecl, namespace_decl, and scope_type_decl.

Definition at line 8501 of file abg-ir.cc.

◆ remove_member_decl()

void remove_member_decl ( decl_base_sptr  member)
protectedvirtual

Remove a declaration from the current scope.

Parameters
memberthe declaration to remove from the scope.

Reimplemented in class_or_union.

Definition at line 8386 of file abg-ir.cc.

◆ remove_member_type()

void remove_member_type ( type_base_sptr  t)

Remove a member type from the current class_or_union scope.

Parameters
tthe type to remove.

Definition at line 8315 of file abg-ir.cc.

◆ traverse()

bool traverse ( ir_node_visitor v)
virtual

This implements the ir_traversable_base::traverse pure virtual function.

Parameters
vthe visitor used on the current instance of scope_decl and on its member nodes.
Returns
true if the traversal of the tree should continue, false otherwise.

Reimplemented from decl_base.

Reimplemented in union_decl, class_decl, class_or_union, class_tdecl, function_tdecl, namespace_decl, and scope_type_decl.

Definition at line 8595 of file abg-ir.cc.

Friends And Related Function Documentation

◆ add_decl_to_scope

decl_base_sptr add_decl_to_scope ( decl_base_sptr  decl,
scope_decl scope 
)
friend

Appends a declaration to a given scope, if the declaration doesn't already belong to one and if the declaration is not for a type that is supposed to be unique.

Parameters
declthe declaration to add to the scope
scopethe scope to append the declaration to

Definition at line 8625 of file abg-ir.cc.

◆ insert_decl_into_scope

decl_base_sptr insert_decl_into_scope ( decl_base_sptr  decl,
scope_decl::declarations::iterator  before,
scope_decl scope 
)
friend

Inserts a declaration into a given scope, before a given IR child node of the scope.

Parameters
declthe declaration to insert into the scope.
beforean iterator pointing to the child IR node before which to insert the declaration.
scopethe scope into which to insert the declaration.

Definition at line 8668 of file abg-ir.cc.

◆ remove_decl_from_scope

void remove_decl_from_scope ( decl_base_sptr  decl)
friend

Remove a given decl from its scope.

Parameters
declthe decl to remove from its scope.

Definition at line 8649 of file abg-ir.cc.


The documentation for this class was generated from the following files: