cppcheck: mitigate performance warnings

* include/abg-diff-utils.h (print_snake): pass argument of type
	snake by const reference.
	* include/abg-ir.h (location::operator{==,<}): Likewise.
	* include/abg-viz-dot.h (node_base::{node_base,parent_node,child_node}):
	Likewise.
	* include/abg-viz-svg.h (svg::svg) Likewise.
	* src/abg-config.cc (config::config): Member initialization in ctor body.
	* src/abg-dwarf-reader.cc (class_decl_sptr::add_or_update_class_type):
	Initial value never used.
	* src/abg-ir.cc: (decl_base::priv::priv) Member initialization in ctor body,
	pass argument of type location by const reference.
	(equals): Variable initial value never used.
	* src/abg-reader.cc (read_corpus_from_input): Initial variable
	value never used.
	(build_elf_symbol_db): Use pre-increment.
	* src/abg-suppression-priv.h
	(suppression_matches_type_location): Pass argument of type
	location by const reference.
	* src/abg-suppression.cc: Likewise.

Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
This commit is contained in:
Ondrej Oprala 2017-04-12 09:53:10 +02:00 committed by Dodji Seketeli
parent 4a2a93c219
commit 0e88e12f05
10 changed files with 19 additions and 23 deletions

View File

@ -1255,7 +1255,7 @@ template<typename RandomAccessOutputIterator>
void
print_snake(RandomAccessOutputIterator a_begin,
RandomAccessOutputIterator b_begin,
const snake s, ostream& out)
const snake &s, ostream& out)
{
if (s.is_empty())
return;

View File

@ -245,7 +245,7 @@ public:
///
/// @return true iff both locations are equal.
bool
operator==(const location other) const
operator==(const location &other) const
{return value_ == other.value_;}
/// "Less than" operator of the @ref location type.
@ -255,7 +255,7 @@ public:
/// @return true iff the current instance is less than the @p other
/// one.
bool
operator<(const location other) const
operator<(const location &other) const
{return value_ < other.value_;}
/// Expand the current location into a tripplet file path, line and

View File

@ -43,7 +43,7 @@ struct node_base
const style& _M_style;
explicit
node_base(std::string __id, type __t, const style& __sty)
node_base(const std::string& __id, type __t, const style& __sty)
: _M_id(__id), _M_count(++_M_count_total),
_M_type(__t), _M_x_space(0.4), _M_y_space(0.2), _M_style(__sty)
{ }
@ -66,7 +66,7 @@ extern const style child_sty;
*/
struct parent_node : public node_base
{
parent_node(std::string __id)
parent_node(const std::string& __id)
: node_base(__id, node_base::parent, parent_sty)
{ }
};
@ -83,7 +83,7 @@ struct parent_node : public node_base
*/
struct child_node : public node_base
{
child_node(std::string __id)
child_node(const std::string& __id)
: node_base(__id, node_base::child, child_sty)
{ }
};
@ -118,7 +118,7 @@ private:
public:
dot(const std::string __title,
dot(const std::string &__title,
const canvas& __cv = ansi_letter_canvas,
const typography& __typo = arial_typo)
: _M_title(__title), _M_canvas(__cv), _M_typo(__typo)

View File

@ -99,7 +99,7 @@ private:
public:
svg(const std::string __title,
svg(const std::string &__title,
const canvas& __cv = ansi_letter_canvas,
const typography& __typo = arial_typo)
: _M_title(__title), _M_canvas(__cv), _M_typo(__typo), _M_y_size(0)

View File

@ -35,10 +35,10 @@ namespace abigail
config::config()
: m_format_minor("0"),
m_format_major("1"),
m_xml_element_indent(2)
m_xml_element_indent(2),
m_tu_instr_suffix(".bi"),
m_tu_instr_archive_suffix(".abi")
{
m_tu_instr_suffix = ".bi" ;
m_tu_instr_archive_suffix = ".abi";
}
const std::string&

View File

@ -11027,8 +11027,7 @@ add_or_update_class_type(read_context& ctxt,
continue;
int64_t offset_in_bits = 0;
bool is_laid_out = false;
is_laid_out = die_member_offset(&child, offset_in_bits);
bool is_laid_out = die_member_offset(&child, offset_in_bits);
// For now, is_static == !is_laid_out. When we have
// templates, we'll try to be more specific. For now,
// this approximation should do OK.

View File

@ -2599,14 +2599,14 @@ struct decl_base::priv
location_(locus),
context_(),
name_(name),
qualified_name_(name),
linkage_name_(linkage_name),
visibility_(vis)
{
qualified_name_ = name;
is_anonymous_ = name_.empty();
}
priv(location l)
priv(const location& l)
: in_pub_sym_tab_(false),
is_anonymous_(true),
location_(l),
@ -9959,9 +9959,7 @@ scope_type_decl::scope_type_decl(const environment* env,
bool
equals(const scope_type_decl& l, const scope_type_decl& r, change_kind* k)
{
bool result = true;
result = equals(static_cast<const scope_decl&>(l),
bool result = equals(static_cast<const scope_decl&>(l),
static_cast<const scope_decl&>(r),
k);

View File

@ -1768,10 +1768,9 @@ read_corpus_from_input(read_context& ctxt)
corp.set_needed(needed);
string_elf_symbols_map_sptr fn_sym_db, var_sym_db;
bool is_ok = false;
// Read the symbol databases.
is_ok = read_symbol_db_from_input(ctxt, fn_sym_db, var_sym_db);
bool is_ok = read_symbol_db_from_input(ctxt, fn_sym_db, var_sym_db);
if (is_ok)
{
assert(fn_sym_db || var_sym_db);
@ -2556,7 +2555,7 @@ build_elf_symbol_db(read_context& ctxt,
while (std::getline(aliases, item, ','))
elems.push_back(item);
for (std::vector<string>::iterator alias = elems.begin();
alias != elems.end(); alias++)
alias != elems.end(); ++alias)
{
string_elf_symbol_sptr_map_type::const_iterator i =
id_sym_map.find(*alias);

View File

@ -774,7 +774,7 @@ suppression_matches_type_name(const suppr::type_suppression& s,
bool
suppression_matches_type_location(const type_suppression& s,
const location loc);
const location& loc);
bool
suppression_matches_type_location(const type_suppression& s,

View File

@ -912,7 +912,7 @@ suppression_matches_type_name(const suppr::type_suppression& s,
/// @return true iff the suppression @p s matches location @p loc.
bool
suppression_matches_type_location(const type_suppression& s,
const location loc)
const location& loc)
{
if (loc)
{