mirror of
git://sourceware.org/git/libabigail.git
synced 2025-01-14 05:10:56 +00:00
82e83d9c5e
* include/abg-fwd.h (fqn_to_components) (lookup_type_in_translation_unit, demangle_cplus_mangled_name): Declare new public entry points * src/abg-comparison.cc (corpus_diff::report): Report stuff about global variables using their mangled name, and demangle them. If there is no mangled name for the variable, then use its pretty representation. (compute_diff): For the corpus overload, compare global variables using their mangled name, if its available; otherwise, fall back to using their pretty representation. * src/abg-corpus.cc (var_comp::operator()(const var_decl*, const_var_decl*)): Compare variables using their mangled name in priority. If it's not available then use their pretty representation. * src/abg-dwarf-reader.cc (read_context::var_decls_to_re_add_to_tree): New accessor. (build_translation_unit_and_add_to_ir): If there is what appears to be a definition of a static member variable variable -- this is in case this definition lacks the DW_AT_specification attribute that links it to the DW_TAG_member or DW_TAG_variable DIE that is a child of the right class/structure DIE -- that is not at the right place in the DIE tree, remove it from the its current place in the tree and try to hang it off of the right DIE. To do this, de-mangle its mangled name, look at what is supposed to be the parent class name, look it up in the translation unit IR, and if found, stick the variable IR node in there, as a static member variable. If not found, then bad luck. (build_class_type_and_add_to_ir): Do not try to see if a member variable is static here as the way I was doing it was unreliable. Build the data member node directly w/o going through building a variable node first. Register the data member in the die offset -> IR node map. (build_ir_node_from_die): When seeing DW_TAG_variable, look for a DW_AT_specification attribute. If there is one, then it points to a the DIE of a data member and means that data member is static. Flag the IR node of that data member as static thus. Update the die offset -> IR node map. If there is no DW_AT_specification attribute or if it doesn't point to a data member DIE, schedule this variable tag for a stage when after the whole IR is built for the translation unit, the variable's mangled named is inspected, its hypothetical parent struct/class is looked up and the variable IR node is put into the node of the right struct/class IR node. * src/abg-ir.cc (enum lookup_entity_kind): New. (fqn_to_components, iterator, lookup_type_in_translation_unit) (lookup_node_in_translation_unit, lookup_type_in_translation_unit) (demangle_cplus_mangled_name): New function definitions. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
272 lines
6.0 KiB
C++
272 lines
6.0 KiB
C++
// -*- Mode: C++ -*-
|
|
//
|
|
// Copyright (C) 2013 Red Hat, Inc.
|
|
//
|
|
// This file is part of the GNU Application Binary Interface Generic
|
|
// Analysis and Instrumentation Library (libabigail). This library is
|
|
// free software; you can redistribute it and/or modify it under the
|
|
// terms of the GNU Lesser General Public License as published by the
|
|
// Free Software Foundation; either version 3, or (at your option) any
|
|
// later version.
|
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
// General Lesser Public License for more details.
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
// License along with this program; see the file COPYING-LGPLV3. If
|
|
// not, see <http://www.gnu.org/licenses/>.
|
|
|
|
/// @file
|
|
|
|
#ifndef __ABG_IRFWD_H__
|
|
#define __ABG_IRFWD_H__
|
|
|
|
#include <cstddef>
|
|
#include <tr1/memory>
|
|
#include <list>
|
|
#include <vector>
|
|
#include <string>
|
|
#include <tr1/functional>
|
|
#include <typeinfo>
|
|
#include <utility> // for std::rel_ops, at least.
|
|
#include <ostream>
|
|
#include "abg-hash.h"
|
|
|
|
/// Toplevel namespace for libabigail.
|
|
namespace abigail
|
|
{
|
|
/**
|
|
@mainpage libabigail
|
|
|
|
|
|
The GNU Application Binary Interface Generic Analysis and
|
|
Instrumentation Library.
|
|
|
|
This is an interface to the GNU Compiler Collection for the
|
|
collection and analysis of compiler-generated binaries.
|
|
|
|
Checkout out the project homepage <a
|
|
href="http://sourceware.org/libabigail"> here</a>.
|
|
|
|
The current libabigail source code can be checked out with:
|
|
git clone git://sourceware.org/git/libabigail.git.
|
|
|
|
The mailing list to send messages and patches to is
|
|
libabigail@sourceware.org.
|
|
*/
|
|
|
|
// Inject some types.
|
|
using std::tr1::shared_ptr;
|
|
using std::string;
|
|
using std::vector;
|
|
|
|
// Pull in relational operators.
|
|
using namespace std::rel_ops;
|
|
|
|
// Forward declarations for corpus.
|
|
|
|
class corpus;
|
|
|
|
// Forward declarations for ir.
|
|
class location;
|
|
class location_manager;
|
|
class translation_unit;
|
|
class class_decl;
|
|
class class_tdecl;
|
|
class decl_base;
|
|
class enum_type_decl;
|
|
class function_decl;
|
|
class function_tdecl;
|
|
class function_type;
|
|
class global_scope;
|
|
class node_visitor;
|
|
class location;
|
|
class location_manager;
|
|
class method_type;
|
|
class namespace_decl;
|
|
class parameter;
|
|
class pointer_type_def;
|
|
class qualified_type_def;
|
|
class reference_type_def;
|
|
class scope_decl;
|
|
class scope_type_decl;
|
|
class template_decl;
|
|
class template_parameter;
|
|
class non_type_tparameter;
|
|
class type_tparameter;
|
|
class template_tparameter;
|
|
|
|
class type_composition;
|
|
class type_base;
|
|
class type_decl;
|
|
class typedef_decl;
|
|
class var_decl;
|
|
|
|
struct type_shared_ptr_equal;
|
|
struct traversable_base;
|
|
|
|
shared_ptr<decl_base>
|
|
add_decl_to_scope(shared_ptr<decl_base>, scope_decl*);
|
|
|
|
shared_ptr<decl_base>
|
|
add_decl_to_scope (shared_ptr<decl_base>, shared_ptr<scope_decl>);
|
|
|
|
const global_scope*
|
|
get_global_scope(const shared_ptr<decl_base>);
|
|
|
|
translation_unit*
|
|
get_translation_unit(const shared_ptr<decl_base>);
|
|
|
|
translation_unit*
|
|
get_translation_unit(decl_base*);
|
|
|
|
bool
|
|
is_global_scope(const scope_decl*);
|
|
|
|
bool
|
|
is_global_scope(const shared_ptr<scope_decl>);
|
|
|
|
bool
|
|
is_at_global_scope(const shared_ptr<decl_base>);
|
|
|
|
bool
|
|
is_at_class_scope(const shared_ptr<decl_base>);
|
|
|
|
bool
|
|
is_at_template_scope(const shared_ptr<decl_base>);
|
|
|
|
bool
|
|
is_template_parameter(const shared_ptr<decl_base>);
|
|
|
|
bool
|
|
is_type(const decl_base&);
|
|
|
|
shared_ptr<type_base>
|
|
is_type(const shared_ptr<decl_base>);
|
|
|
|
shared_ptr<type_base>
|
|
as_non_member_type(const shared_ptr<type_base>);
|
|
|
|
shared_ptr<type_base>
|
|
as_non_member_type(const shared_ptr<decl_base>);
|
|
|
|
shared_ptr<class_decl>
|
|
as_non_member_class_decl(const shared_ptr<decl_base>);
|
|
|
|
const class_decl*
|
|
as_non_member_class_decl(const decl_base* t);
|
|
|
|
bool
|
|
is_var_decl(const shared_ptr<decl_base>);
|
|
|
|
bool
|
|
is_template_parm_composition_type(const shared_ptr<decl_base>);
|
|
|
|
bool
|
|
is_template_decl(const shared_ptr<decl_base>);
|
|
|
|
bool
|
|
is_function_template_pattern(const shared_ptr<decl_base>);
|
|
|
|
shared_ptr<decl_base>
|
|
add_decl_to_scope(shared_ptr<decl_base>, scope_decl*);
|
|
|
|
shared_ptr<decl_base>
|
|
add_decl_to_scope(shared_ptr<decl_base>, shared_ptr<scope_decl>);
|
|
|
|
shared_ptr<decl_base>
|
|
insert_decl_into_scope(shared_ptr<decl_base>,
|
|
vector<shared_ptr<decl_base> >::iterator,
|
|
scope_decl*);
|
|
|
|
shared_ptr<decl_base>
|
|
insert_decl_into_scope(shared_ptr<decl_base>,
|
|
vector<shared_ptr<decl_base> >::iterator,
|
|
shared_ptr<scope_decl>);
|
|
|
|
void
|
|
remove_decl_from_scope(shared_ptr<decl_base>);
|
|
|
|
const global_scope*
|
|
get_global_scope(const decl_base* decl);
|
|
|
|
translation_unit*
|
|
get_translation_unit(decl_base* decl);
|
|
|
|
translation_unit*
|
|
get_translation_unit(const shared_ptr<decl_base>);
|
|
|
|
string
|
|
get_type_name(const shared_ptr<type_base>);
|
|
|
|
const decl_base*
|
|
get_type_declaration(const type_base*);
|
|
|
|
decl_base*
|
|
get_type_declaration(type_base*);
|
|
|
|
shared_ptr<decl_base>
|
|
get_type_declaration(const shared_ptr<type_base>);
|
|
|
|
const scope_decl*
|
|
get_top_most_scope_under(const decl_base*,
|
|
const scope_decl*);
|
|
|
|
const scope_decl*
|
|
get_top_most_scope_under(const shared_ptr<decl_base>,
|
|
const scope_decl*);
|
|
|
|
const scope_decl*
|
|
get_top_most_scope_under(const shared_ptr<decl_base>,
|
|
const shared_ptr<scope_decl>);
|
|
|
|
void
|
|
fqn_to_components(const std::string&,
|
|
std::list<string>&);
|
|
|
|
const shared_ptr<decl_base>
|
|
lookup_type_in_translation_unit(const string&,
|
|
const translation_unit&);
|
|
|
|
const shared_ptr<decl_base>
|
|
lookup_type_in_translation_unit(const std::list<string>&,
|
|
const translation_unit&);
|
|
|
|
string
|
|
demangle_cplus_mangled_name(const string&);
|
|
|
|
void
|
|
dump(const shared_ptr<decl_base>, std::ostream&);
|
|
|
|
void
|
|
dump(const shared_ptr<decl_base>);
|
|
|
|
void
|
|
dump(const shared_ptr<type_base>, std::ostream&);
|
|
|
|
void
|
|
dump(const shared_ptr<type_base>);
|
|
|
|
void
|
|
dump(const shared_ptr<var_decl>, std::ostream&);
|
|
|
|
void
|
|
dump(const shared_ptr<var_decl>);
|
|
|
|
void
|
|
dump(const translation_unit&, std::ostream&);
|
|
|
|
void
|
|
dump(const translation_unit&);
|
|
|
|
void
|
|
dump(const shared_ptr<translation_unit>, std::ostream&);
|
|
|
|
void
|
|
dump(const shared_ptr<translation_unit>);
|
|
|
|
} // end namespace abigail
|
|
#endif // __ABG_IRFWD_H__
|