libabigail
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Friends | List of all members
decl_base Class Reference

The base type of all declarations. More...

#include <abg-ir.h>

Inheritance diagram for decl_base:
[legend]

Public Types

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

 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...
 
virtual size_t get_hash () const
 Get the hash of a decl. If the hash hasn't been computed yet, compute it ans store its value; otherwise, just return the hash. 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...
 
virtual bool operator== (const decl_base &) const
 Return true iff the two decls have the same name. 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...
 
virtual bool traverse (ir_node_visitor &v)
 This implements the ir_traversable_base::traverse pure virtual function. 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...
 

Public Attributes

priv * priv_
 

Protected Member Functions

 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 *scpe)
 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...
 
class class_decl
 
class class_or_union
 
bool equals (const decl_base &, const decl_base &, change_kind *)
 Compares two instances of decl_base. More...
 
bool equals (const var_decl &, const var_decl &, change_kind *)
 Compares two instances of var_decl. More...
 
enum access_specifier get_member_access_specifier (const decl_base &d)
 Gets the access specifier for a class member. More...
 
enum access_specifier get_member_access_specifier (const decl_base_sptr &d)
 Gets the access specifier for a class member. More...
 
bool get_member_function_is_virtual (const function_decl &f)
 Test if a given member function is virtual. More...
 
bool get_member_is_static (const decl_base &d)
 Gets a flag saying if a class member is static or not. More...
 
bool get_member_is_static (const decl_base_sptr &d)
 Gets a flag saying if a class member is static or not. More...
 
decl_base_sptr insert_decl_into_scope (decl_base_sptr, vector< shared_ptr< decl_base > >::iterator, scope_decl *)
 
bool maybe_compare_as_member_decls (const decl_base &l, const decl_base &r, change_kind *k)
 Compare the properties that belong to the "is-a-member-relation" of a decl. More...
 
void remove_decl_from_scope (decl_base_sptr)
 Remove a given decl from its scope. More...
 
class scope_decl
 
void set_member_access_specifier (decl_base &d, access_specifier a)
 Sets the access specifier for a class member. More...
 
void set_member_function_is_virtual (function_decl &, bool)
 Set the virtual-ness of a member function. More...
 
void set_member_is_static (const decl_base_sptr &d, bool s)
 Sets the static-ness property of a class member. More...
 
void set_member_is_static (decl_base &d, bool s)
 Sets the static-ness property of a class member. More...
 
bool var_equals_modulo_types (const var_decl &, const var_decl &, change_kind *)
 Compares two instances of var_decl without taking their type into account. More...
 

Additional Inherited Members

- 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

The base type of all declarations.

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

Member Enumeration Documentation

◆ binding

enum binding

ELF binding.

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

◆ visibility

enum visibility

ELF visibility.

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

Constructor & Destructor Documentation

◆ decl_base() [1/3]

decl_base ( const environment e,
const string &  name,
const location locus,
const string &  linkage_name = "",
visibility  vis = VISIBILITY_DEFAULT 
)

Constructor for the decl_base type.

Parameters
ethe environment the current decl_base is being created in.
namethe name of the declaration.
locusthe location where to find the declaration in the source code.
linkage_namethe linkage name of the declaration.
visthe visibility of the declaration.

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

◆ decl_base() [2/3]

decl_base ( const environment e,
const interned_string name,
const location locus,
const interned_string linkage_name = interned_string(),
visibility  vis = VISIBILITY_DEFAULT 
)

Constructor.

Parameters
ethe environment this instance of decl_base is created in.
namethe name of the declaration being constructed.
locusthe source location of the declaration being constructed.
linkage_namethe linkage name of the declaration being constructed.
visthe visibility of the declaration being constructed.

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

◆ decl_base() [3/3]

decl_base ( const environment e,
const location l 
)

Constructor for the decl_base type.

Parameters
environmentthe environment this instance of decl_base is being constructed in.
lthe location where to find the declaration in the source code.

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

◆ ~decl_base()

~decl_base ( )
virtual

Destructor of the decl_base type.

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

Member Function Documentation

◆ clear_qualified_name()

void clear_qualified_name ( )
protected

Clear the qualified name of this decl.

This is useful to ensure that the cache for the qualified name of the decl is refreshed right after type canonicalization, for instance.

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

◆ get_context_rel() [1/2]

context_rel * get_context_rel ( )
protected

Getter for the context relationship.

Returns
the context relationship for the current decl_base.

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

◆ get_context_rel() [2/2]

const context_rel * get_context_rel ( ) const
protected

Getter for the context relationship.

Returns
the context relationship for the current decl_base.

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

◆ get_definition_of_declaration()

const decl_base_sptr get_definition_of_declaration ( ) const

If this decl_base is declaration-only, get its definition, if any.

Returns
the definition of this decl-only decl_base.

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

◆ get_earlier_declaration()

const decl_base_sptr get_earlier_declaration ( ) const

If this decl_base is a definition, get its earlier declaration.

Returns
the earlier declaration of the class, if any.

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

◆ get_has_anonymous_parent()

bool get_has_anonymous_parent ( ) const

Get the "has_anonymous_parent" flag of the current declaration.

Having an anoymous parent means having a anonymous parent scope (containing type or namespace) which is either direct or indirect.

Returns
true iff the current decl has a direct or indirect scope which is anonymous.

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

◆ get_hash()

size_t get_hash ( ) const
virtual

Get the hash of a decl. If the hash hasn't been computed yet, compute it ans store its value; otherwise, just return the hash.

Returns
the hash of the decl.

Reimplemented in class_decl::base_spec, class_decl, type_composition, non_type_tparameter, function_decl::parameter, function_decl, var_decl, and scope_decl.

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

◆ get_is_anonymous()

bool get_is_anonymous ( ) const

Test if the current declaration is anonymous.

Being anonymous means that the declaration was created without a name. This can usually happen for enum or struct types.

Returns
true iff the type is anonymous.

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

◆ get_is_anonymous_or_has_anonymous_parent()

bool get_is_anonymous_or_has_anonymous_parent ( ) const
Returns
the logical "OR" of decl_base::get_is_anonymous() and decl_base::get_has_anonymous_parent().

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

◆ get_is_declaration_only()

bool get_is_declaration_only ( ) const

Test if a decl_base is a declaration-only decl.

Returns
true iff the current decl_base is declaration-only.

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

◆ get_is_in_public_symbol_table()

bool get_is_in_public_symbol_table ( ) const

Test if the decl is defined in a ELF symbol table as a public symbol.

Returns
true iff the decl is defined in a ELF symbol table as a public symbol.

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

◆ get_linkage_name()

const interned_string & get_linkage_name ( ) const

Getter for the mangled name.

Returns
the new mangled name.

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

◆ get_location()

const location & get_location ( ) const

Get the location of a given declaration.

The location is an abstraction for the tripplet {file path, line, column} that defines where the declaration appeared in the source code.

To get the value of the tripplet {file path, line, column} from the location, you need to use the location_manager::expand_location() method.

The instance of location_manager that you want is accessible from the instance of translation_unit that the current instance of decl_base belongs to, via a call to translation_unit::get_loc_mgr().

Returns
the location of the current instance of decl_base.

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

◆ get_naked_definition_of_declaration()

const decl_base * get_naked_definition_of_declaration ( ) const

If this decl_base is declaration-only, get its definition, if any.

Note that this function doesn't return a smart pointer, but rather the underlying pointer managed by the smart pointer. So it's as fast as possible. This getter is to be used in code paths that are proven to be performance hot spots; especially, when comparing sensitive types like enums, classes or unions. Those are compared extremely frequently and thus, their access to the definition of declaration must be fast.

Returns
the definition of the declaration.

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

◆ get_name()

const interned_string & get_name ( ) const

Getter for the name of the current decl.

Returns
the name of the current decl.

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

◆ get_naming_typedef()

typedef_decl_sptr get_naming_typedef ( ) const

Getter for the naming typedef of the current decl.

Consider the C idiom:

typedef struct {int member;} foo_type;

In that idiom, foo_type is the naming typedef of the anonymous struct that is declared.

Returns
the naming typedef, if any. Otherwise, returns nil.

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

◆ get_pretty_representation()

string get_pretty_representation ( bool  internal = false,
bool  qualified_name = true 
) const
virtual

Get the pretty representatin of the current declaration.

Parameters
internalset to true if the call is intended to get a representation of the decl (or type) for the purpose of canonical type comparison. This is mainly used in the function type_base::get_canonical_type_for().

In other words if the argument for this parameter is true then the call is meant for internal use (for technical use inside the library itself), false otherwise. If you don't know what this is for, then set it to false.

Parameters
qualified_nameif true, names emitted in the pretty representation are fully qualified.
Returns
the default pretty representation for a decl. This is basically the fully qualified name of the decl optionally prefixed with a meaningful string to add context for the user.

Implements type_or_decl_base.

Reimplemented in union_decl, class_decl, function_decl::parameter, function_decl, var_decl, typedef_decl, enum_type_decl, array_type_def, array_type_def::subrange_type, reference_type_def, namespace_decl, and type_decl.

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

◆ get_qualified_name() [1/2]

const interned_string & get_qualified_name ( bool  internal = false) const
virtual

Return the qualified name of the decl.

This is the fully qualified name of the decl. It's made of the concatenation of the name of the decl with the qualified name of its scope.

Note that the value returned by this function is computed by update_qualified_name when the decl is added to its scope.

Parameters
internalset to true if the call is intended for an internal use (for technical use inside the library itself), false otherwise. If you don't know what this is for, then set it to false.
Returns
the resulting qualified name.

Reimplemented in var_decl, typedef_decl, array_type_def, ptr_to_mbr_type, reference_type_def, pointer_type_def, qualified_type_def, and type_decl.

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

◆ get_qualified_name() [2/2]

void get_qualified_name ( interned_string qn,
bool  internal = false 
) const
virtual

Compute the qualified name of the decl.

Parameters
qnthe resulting qualified name.
internalset to true if the call is intended for an internal use (for technical use inside the library itself), false otherwise. If you don't know what this is for, then set it to false.

Reimplemented in function_decl::parameter, typedef_decl, array_type_def, ptr_to_mbr_type, reference_type_def, qualified_type_def, type_decl, and pointer_type_def.

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

◆ get_qualified_parent_name()

const interned_string & get_qualified_parent_name ( ) const

Return a copy of the qualified name of the parent of the current decl.

Returns
the newly-built qualified name of the of the current decl.

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

◆ get_scope()

scope_decl * get_scope ( ) const

Return the type containing the current decl, if any.

Returns
the type that contains the current decl, or NULL if there is none.

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

◆ get_scoped_name()

const interned_string & get_scoped_name ( ) const
virtual

Return the scoped name of the decl.

This is made of the concatenation of the name of the decl with the name of its scope. It doesn't contain the qualified name of its scope, unlike what is returned by decl_base::get_qualified_name.

Note that the value returned by this function is computed by update_qualified_name when the decl is added to its scope.

Returns
the scoped name of the decl.

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

◆ get_visibility()

decl_base::visibility get_visibility ( ) const

Getter for the visibility of the decl.

Returns
the new visibility.

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

◆ operator!=()

bool operator!= ( const decl_base other) const
virtual

Inequality operator.

Parameters
otherto other instance of decl_base to compare the current instance to.
Returns
true iff the current instance of decl_base is different from other.

Reimplemented in array_type_def::subrange_type, and type_decl.

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

◆ operator==()

bool operator== ( const decl_base other) const
virtual

Return true iff the two decls have the same name.

This function doesn't test if the scopes of the the two decls are equal.

Note that this virtual function is to be implemented by classes that extend the decl_base class.

Reimplemented in template_decl, function_decl, member_class_template, union_decl, class_decl::base_spec, class_decl, class_or_union, class_tdecl, function_tdecl, template_tparameter, non_type_tparameter, type_tparameter, function_decl::parameter, var_decl, typedef_decl, enum_type_decl, array_type_def, array_type_def::subrange_type, ptr_to_mbr_type, reference_type_def, pointer_type_def, qualified_type_def, namespace_decl, scope_type_decl, type_decl, and scope_decl.

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

◆ peek_qualified_name()

const interned_string & peek_qualified_name ( ) const
protected

Getter for the qualified name.

Unlike decl_base::get_qualified_name() this doesn't try to update the qualified name.

Returns
the qualified name.

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

◆ peek_temporary_qualified_name()

const interned_string & peek_temporary_qualified_name ( ) const
protected

Getter of the temporary qualified name of the current declaration.

This temporary qualified name is used as a qualified name cache by the type for which this is the declaration (when applicable) before the type is canonicalized. Once the type is canonicalized, it's the result of decl_base::peek_qualified_name() that becomes the qualified name cached.

Returns
the temporary qualified name.

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

◆ set_definition_of_declaration()

void set_definition_of_declaration ( const decl_base_sptr &  d)

Set the definition of this declaration-only decl_base.

Parameters
dthe new definition to set.

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

◆ set_earlier_declaration()

void set_earlier_declaration ( const decl_base_sptr &  d)

set the earlier declaration of this decl_base definition.

Parameters
dthe earlier declaration to set. Note that it's set only if it's a pure declaration.

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

◆ set_is_anonymous()

void set_is_anonymous ( bool  f)

Set the "is_anonymous" flag of the current declaration.

Being anonymous means that the declaration was created without a name. This can usually happen for enum or struct types.

Parameters
fthe new value of the flag.

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

◆ set_is_declaration_only()

void set_is_declaration_only ( bool  f)

Set a flag saying if the enum_type_decl is a declaration-only enum_type_decl.

Parameters
ftrue if the enum_type_decl is a declaration-only enum_type_decl.

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

◆ set_is_in_public_symbol_table()

void set_is_in_public_symbol_table ( bool  f)

Set the flag saying if this decl is from a symbol that is in a public symbols table, defined as public (global or weak).

Parameters
fthe new flag value.

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

◆ set_linkage_name()

void set_linkage_name ( const string &  m)
virtual

Setter for the linkage name.

Parameters
mthe new linkage name.

Reimplemented in method_decl.

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

◆ set_location()

void set_location ( const location l)

Set the location for a given declaration.

The location is an abstraction for the tripplet {file path, line, column} that defines where the declaration appeared in the source code.

To create a location from a tripplet {file path, line, column}, you need to use the method location_manager::create_new_location().

Note that there can be two kinds of location. An artificial location and a non-artificial one. The non-artificial location is the one emitted by the original emitter of the ABI artifact, for instance, if the ABI artifact comes from debug info, then the source location that is present in the debug info represent a non-artificial location. When looking at an abixml file on the other hand, the value of the 'location' attribute of an XML element describing an artifact is the non-artificial location. The artificial location is the location (line number from the beginning of the file) of the XML element within the abixml file.

So, if the location that is being set is artificial, note that the type_or_decl_base::has_artificial_location() method of this decl will subsequently return true and that artificial location will have to be retrieved using type_or_decl_base::get_artificial_location(). If the location is non-artificial however, type_or_decl_base::has_artificial_location() will subsequently return false and the non-artificial location will have to be retrieved using decl_base::get_location().

The instance of location_manager that you want is accessible from the instance of translation_unit that the current instance of decl_base belongs to, via a call to translation_unit::get_loc_mgr().

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

◆ set_name()

void set_name ( const string &  n)

Setter for the name of the decl.

Parameters
nthe new name to set.

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

◆ set_naming_typedef()

void set_naming_typedef ( const typedef_decl_sptr t)

Set the naming typedef of the current instance of decl_base.

Consider the C idiom:

typedef struct {int member;} foo_type;

In that idiom, foo_type is the naming typedef of the anonymous struct that is declared.

After completion of this function, the decl will not be considered anonymous anymore. It's name is going to be the name of the naming typedef.

Parameters
typedef_typethe new naming typedef.

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

◆ set_qualified_name()

void set_qualified_name ( const interned_string n) const
protected

Setter for the qualified name.

Parameters
nthe new qualified name.

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

◆ set_scope()

void set_scope ( scope_decl scope)
virtual

Setter of the scope of the current decl.

Note that the decl won't hold a reference on the scope. It's rather the scope that holds a reference on its members.

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

◆ set_temporary_qualified_name()

void set_temporary_qualified_name ( const interned_string n) const
protected

Setter for the temporary qualified name of the current declaration.

Parameters
nthe new temporary qualified name.

This temporary qualified name is used as a qualified name cache by the type for which this is the declaration (when applicable) before the type is canonicalized. Once the type is canonicalized, it's the result of decl_base::peek_qualified_name() that becomes the qualified name cached.

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

◆ set_visibility()

void set_visibility ( visibility  v)

Setter for the visibility of the decl.

Parameters
vthe new visibility.

Definition at line 5024 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 member nodes of the translation unit during the traversal.
Returns
true if the entire IR node tree got traversed, false otherwise.

Reimplemented from type_or_decl_base.

Reimplemented in member_class_template, union_decl, class_decl, class_or_union, class_tdecl, function_tdecl, function_decl::parameter, var_decl, enum_type_decl, array_type_def, ptr_to_mbr_type, reference_type_def, pointer_type_def, qualified_type_def, member_function_template, class_decl::base_spec, function_decl, typedef_decl, array_type_def::subrange_type, namespace_decl, scope_type_decl, type_decl, and scope_decl.

Definition at line 5477 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 scpe 
)
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.

◆ equals [1/2]

bool equals ( const decl_base ,
const decl_base ,
change_kind  
)
friend

Compares two instances of decl_base.

If the two intances are different, set a bitfield to give some insight about the kind of differences there are.

Parameters
lthe first artifact of the comparison.
rthe second artifact of the comparison.
ka pointer to a bitfield that gives information about the kind of changes there are between l and r. This one is set iff it's non-null and if the function returns false.

Please note that setting k to a non-null value does have a negative performance impact because even if l and r are not equal, the function keeps up the comparison in order to determine the different kinds of ways in which they are different.

Returns
true if l equals r, false otherwise.

If both of the current decls have an anonymous scope then let's compare their name component by component by properly handling anonymous scopes. That's the slow path.

Otherwise, let's just compare their name, the obvious way. That's the fast path because in that case the names are interned_string and comparing them is much faster.

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

◆ equals [2/2]

bool equals ( const var_decl ,
const var_decl ,
change_kind  
)
friend

Compares two instances of var_decl.

If the two intances are different, set a bitfield to give some insight about the kind of differences there are.

Parameters
lthe first artifact of the comparison.
rthe second artifact of the comparison.
ka pointer to a bitfield that gives information about the kind of changes there are between l and r. This one is set iff k is non-null and the function returns false.

Please note that setting k to a non-null value does have a negative performance impact because even if l and r are not equal, the function keeps up the comparison in order to determine the different kinds of ways in which they are different.

Returns
true if l equals r, false otherwise.

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

◆ get_member_access_specifier [1/2]

enum access_specifier get_member_access_specifier ( const decl_base d)
friend

Gets the access specifier for a class member.

Parameters
dthe declaration of the class member to consider. Note that this must be a class member otherwise the function aborts the current process.
Returns
the access specifier for the class member d.

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

◆ get_member_access_specifier [2/2]

enum access_specifier get_member_access_specifier ( const decl_base_sptr &  d)
friend

Gets the access specifier for a class member.

Parameters
dthe declaration of the class member to consider. Note that this must be a class member otherwise the function aborts the current process.
Returns
the access specifier for the class member d.

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

◆ get_member_function_is_virtual

bool get_member_function_is_virtual ( const function_decl f)
friend

Test if a given member function is virtual.

Parameters
mem_fnthe member function to consider.
Returns
true iff a mem_fn is virtual.

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

◆ get_member_is_static [1/2]

bool get_member_is_static ( const decl_base d)
friend

Gets a flag saying if a class member is static or not.

Parameters
dthe declaration for the class member to consider. Note that this must be a class member otherwise the function aborts the current process.
Returns
true if the class member d is static, false otherwise.

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

◆ get_member_is_static [2/2]

bool get_member_is_static ( const decl_base_sptr &  d)
friend

Gets a flag saying if a class member is static or not.

Parameters
dthe declaration for the class member to consider. Note that this must be a class member otherwise the function aborts the current process.
Returns
true if the class member d is static, false otherwise.

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

◆ maybe_compare_as_member_decls

bool maybe_compare_as_member_decls ( const decl_base l,
const decl_base r,
change_kind k 
)
friend

Compare the properties that belong to the "is-a-member-relation" of a decl.

For instance, access specifiers are part of the "is-a-member-relation" of a decl.

This comparison however doesn't take decl names into account. So typedefs for instance are decls that we want to compare with this function.

This function is a sub-routine of the more general 'equals' overload for instances of decl_base.

Parameters
lthe left-hand side operand of the comparison.
rthe right-hand side operand of the comparison.
Returns
true iff l compare equals, as a member decl, to r.

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

◆ remove_decl_from_scope

void remove_decl_from_scope ( decl_base_sptr  )
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.

◆ set_member_access_specifier

void set_member_access_specifier ( decl_base d,
access_specifier  a 
)
friend

Sets the access specifier for a class member.

Parameters
dthe class member to set the access specifier for. Note that this must be a class member otherwise the function aborts the current process.
athe new access specifier to set the class member to.

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

◆ set_member_function_is_virtual

void set_member_function_is_virtual ( function_decl ,
bool   
)
friend

Set the virtual-ness of a member function.

Parameters
fthe member function to consider.
is_virtualset to true if the function is virtual.

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

◆ set_member_is_static [1/2]

void set_member_is_static ( const decl_base_sptr &  d,
bool  s 
)
friend

Sets the static-ness property of a class member.

Parameters
dthe class member to set the static-ness property for. Note that this must be a class member otherwise the function aborts the current process.
sthis must be true if the member is to be static, false otherwise.

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

◆ set_member_is_static [2/2]

void set_member_is_static ( decl_base d,
bool  s 
)
friend

Sets the static-ness property of a class member.

Parameters
dthe class member to set the static-ness property for. Note that this must be a class member otherwise the function aborts the current process.
sthis must be true if the member is to be static, false otherwise.

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

◆ var_equals_modulo_types

bool var_equals_modulo_types ( const var_decl ,
const var_decl ,
change_kind  
)
friend

Compares two instances of var_decl without taking their type into account.

If the two intances are different modulo their type, set a bitfield to give some insight about the kind of differences there are.

Parameters
lthe first artifact of the comparison.
rthe second artifact of the comparison.
ka pointer to a bitfield that gives information about the kind of changes there are between l and r. This one is set iff k is non-null and the function returns false.

Please note that setting k to a non-null value does have a negative performance impact because even if l and r are not equal, the function keeps up the comparison in order to determine the different kinds of ways in which they are different.

Returns
true if l equals r, false otherwise.

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


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