From patchwork Fri May 1 15:51:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 39189 From: gprocida@google.com (Giuliano Procida) Date: Fri, 1 May 2020 16:51:44 +0100 Subject: [PATCH v2 1/5] Remove excess whitespace. In-Reply-To: <20200501155148.98623-1-gprocida@google.com> References: <20200429175133.19814-1-gprocida@google.com> <20200501155148.98623-1-gprocida@google.com> Message-ID: <20200501155148.98623-2-gprocida@google.com> This patch removes some excess blank lines and a space after the prefix ++ operator. * src/abg-suppression.cc: Eliminate double blank lines. (read_parameter_spec_from_string): Eliminate space between ++ operator and its operand. Reviewed-by: Matthias Maennich Signed-off-by: Giuliano Procida --- src/abg-suppression.cc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/abg-suppression.cc b/src/abg-suppression.cc index d3ccb63c..d9279c15 100644 --- a/src/abg-suppression.cc +++ b/src/abg-suppression.cc @@ -497,7 +497,6 @@ void type_suppression::set_consider_type_kind(bool f) {priv_->consider_type_kind_ = f;} - /// Setter of the kind of type this suppression is about. /// /// Note that this will be considered during evaluation of the @@ -802,7 +801,6 @@ type_suppression::suppresses_diff(const diff* diff) const range_end_val)) break; - unsigned range_begin = (range_begin_val < 0) ? first_type_size : range_begin_val; @@ -1255,7 +1253,6 @@ type_suppression::insertion_range::integer_boundary_sptr type_suppression::insertion_range::create_integer_boundary(int value) {return integer_boundary_sptr(new integer_boundary(value));} - /// Create a function call expression boundary. /// /// The return value of this function is to be used as a boundary for @@ -3120,7 +3117,7 @@ read_parameter_spec_from_string(const string& str) if (str[cur] == '/') { is_regex = true; - ++ cur; + ++cur; } // look for the type name (regex) @@ -3956,7 +3953,6 @@ variable_suppression::suppresses_variable_symbol(const elf_symbol* sym, else no_symbol_name = true; - // Consider the symbol version. if (!get_symbol_version().empty()) { @@ -4383,7 +4379,6 @@ file_suppression_sptr is_file_suppression(const suppression_sptr s) {return dynamic_pointer_cast(s);} - /// Test if a given file path is "suppressed" by at least one file /// suppression specification among a vector of suppression /// specifications. From patchwork Fri May 1 15:51:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 39191 From: gprocida@google.com (Giuliano Procida) Date: Fri, 1 May 2020 16:51:45 +0100 Subject: [PATCH v2 2/5] Remove stray semicolons. In-Reply-To: <20200501155148.98623-1-gprocida@google.com> References: <20200429175133.19814-1-gprocida@google.com> <20200501155148.98623-1-gprocida@google.com> Message-ID: <20200501155148.98623-3-gprocida@google.com> This patch removes various stray semicolons. * include/abg-diff-utils.h (display_edit_script): Remove redundant semicolon. * include/abg-fwd.h (lookup_basic_type): Ditto. * src/abg-comparison.cc (mark_diff_as_visited): Ditto. (array_diff::has_local_changes): Ditto. (class_diff::ensure_lookup_tables_populated): Ditto. * src/abg-corpus.cc (corpus::priv::build_unreferenced_symbols_tables): Ditto. * src/abg-default-reporter.cc (default_reporter::report): Ditto. * src/abg-dwarf-reader.cc (finish_member_function_reading): Ditto. * src/abg-ir.cc (is_compatible_with_class_type): Ditto. (enum_type_decl::enumerator::set_name): Ditto. * src/abg-reader.cc (read_corpus_from_input): Ditto. (build_function_type): Ditto. * src/abg-suppression.cc (type_suppression::suppresses_type): Ditto. Reviewed-by: Matthias Maennich Signed-off-by: Giuliano Procida --- include/abg-diff-utils.h | 2 +- include/abg-fwd.h | 2 +- src/abg-comparison.cc | 6 +++--- src/abg-corpus.cc | 2 +- src/abg-default-reporter.cc | 2 +- src/abg-dwarf-reader.cc | 3 +-- src/abg-ir.cc | 4 ++-- src/abg-reader.cc | 4 ++-- src/abg-suppression.cc | 4 ++-- 9 files changed, 14 insertions(+), 15 deletions(-) diff --git a/include/abg-diff-utils.h b/include/abg-diff-utils.h index 92171a4a..3cbdbf33 100644 --- a/include/abg-diff-utils.h +++ b/include/abg-diff-utils.h @@ -2046,7 +2046,7 @@ display_edit_script(const edit_script& es, else if (es.num_deletions() == 1) { out << "1 deletion:\n" - << "\t happened at index: ";; + << "\t happened at index: "; } else { diff --git a/include/abg-fwd.h b/include/abg-fwd.h index 1aab70a6..c44d0f5d 100644 --- a/include/abg-fwd.h +++ b/include/abg-fwd.h @@ -993,7 +993,7 @@ type_decl_sptr lookup_basic_type(const string&, const translation_unit&); type_decl_sptr -lookup_basic_type(const type_decl&, const corpus&);; +lookup_basic_type(const type_decl&, const corpus&); type_decl_sptr lookup_basic_type(const string&, const corpus&); diff --git a/src/abg-comparison.cc b/src/abg-comparison.cc index 46bf9e30..399c4b96 100644 --- a/src/abg-comparison.cc +++ b/src/abg-comparison.cc @@ -1320,7 +1320,7 @@ diff_context::mark_diff_as_visited(const diff* d) ABG_ASSERT(canonical); size_t canonical_ptr_value = reinterpret_cast(canonical); - size_t diff_ptr_value = reinterpret_cast(d);; + size_t diff_ptr_value = reinterpret_cast(d); priv_->visited_diff_nodes_[canonical_ptr_value] = diff_ptr_value; } @@ -3676,7 +3676,7 @@ array_diff::has_local_changes() const ir::change_kind k = ir::NO_CHANGE_KIND; if (!equals(*first_array(), *second_array(), &k)) return k & ir::ALL_LOCAL_CHANGES_MASK; - return ir::NO_CHANGE_KIND;; + return ir::NO_CHANGE_KIND; } /// Report the diff in a serialized form. @@ -5204,7 +5204,7 @@ class_diff::ensure_lookup_tables_populated(void) const vector to_delete; corpus_sptr f = context()->get_first_corpus(), - s = context()->get_second_corpus();; + s = context()->get_second_corpus(); if (s) for (string_member_function_sptr_map::const_iterator i = deleted_member_fns().begin(); diff --git a/src/abg-corpus.cc b/src/abg-corpus.cc index 12f44fd1..ebdf8f29 100644 --- a/src/abg-corpus.cc +++ b/src/abg-corpus.cc @@ -416,7 +416,7 @@ corpus::priv::build_unreferenced_symbols_tables() string sym_id = (*s)->get_id_string(); if (refed_vars.find(sym_id) == refed_vars.end()) { - bool keep = sym_id_vars_to_keep.empty() ? true : false;; + bool keep = sym_id_vars_to_keep.empty() ? true : false; for (vector::const_iterator i = sym_id_vars_to_keep.begin(); i != sym_id_vars_to_keep.end(); diff --git a/src/abg-default-reporter.cc b/src/abg-default-reporter.cc index 04e2bb76..5892bec2 100644 --- a/src/abg-default-reporter.cc +++ b/src/abg-default-reporter.cc @@ -1713,7 +1713,7 @@ default_reporter::report(const corpus_diff& d, ostream& out, << c->get_pretty_representation() << "\n"; } - emitted = true;; + emitted = true; } if (emitted) out << "\n"; diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 850281ad..8cbf0046 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -13548,8 +13548,7 @@ finish_member_function_reading(Dwarf_Die* die, if (!f->get_parameters().empty()) first_parm = f->get_parameters()[0]; - bool is_artificial = - first_parm && first_parm->get_is_artificial();; + bool is_artificial = first_parm && first_parm->get_is_artificial(); pointer_type_def_sptr this_ptr_type; type_base_sptr other_klass; diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 27831352..bfcaf5d3 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -7711,7 +7711,7 @@ is_compatible_with_class_type(const type_base_sptr& t) // CPU usage toll in exchange for finer filtering? // type_base_sptr ty = strip_typedef(t); - type_base_sptr ty = peel_typedef_type(t);; + type_base_sptr ty = peel_typedef_type(t); return is_class_type(ty); } @@ -15203,7 +15203,7 @@ enum_type_decl::enumerator::set_name(const string& n) { const environment* env = get_environment(); ABG_ASSERT(env); - priv_->name_ = env->intern(n);; + priv_->name_ = env->intern(n); } /// Getter for the value of @ref enum_type_decl::enumerator. diff --git a/src/abg-reader.cc b/src/abg-reader.cc index 255a200f..2e31f320 100644 --- a/src/abg-reader.cc +++ b/src/abg-reader.cc @@ -2064,7 +2064,7 @@ read_corpus_from_input(read_context& ctxt) ctxt.set_corpus_node(node); } - return ctxt.get_corpus();; + return ctxt.get_corpus(); } /// Parse the input XML document containing an ABI corpus group, @@ -3836,7 +3836,7 @@ build_function_type(read_context& ctxt, environment* env = ctxt.get_environment(); ABG_ASSERT(env); std::vector > parms; - type_base_sptr return_type = env->get_void_type();; + type_base_sptr return_type = env->get_void_type(); class_decl_sptr method_class_type; if (is_method_t) diff --git a/src/abg-suppression.cc b/src/abg-suppression.cc index d9279c15..ab67f40a 100644 --- a/src/abg-suppression.cc +++ b/src/abg-suppression.cc @@ -1159,10 +1159,10 @@ bool type_suppression::suppresses_type(const type_base_sptr& type) const { if (!suppression_matches_type_no_name(*this, type)) - return false;; + return false; if (!suppression_matches_type_name(*this, get_name(type))) - return false;; + return false; return true; } From patchwork Fri May 1 15:51:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 39192 From: gprocida@google.com (Giuliano Procida) Date: Fri, 1 May 2020 16:51:46 +0100 Subject: [PATCH v2 3/5] Eliminate redundant conditional operators. In-Reply-To: <20200501155148.98623-1-gprocida@google.com> References: <20200429175133.19814-1-gprocida@google.com> <20200501155148.98623-1-gprocida@google.com> Message-ID: <20200501155148.98623-4-gprocida@google.com> Code of the form bool x = expression ? true : false; can be written more concisely as bool x = expression; This patch does this. There are no occurences of "? false : true". * src/abg-corpus.cc (corpus::priv::build_unreferenced_symbols_tables): Eliminate redundant conditional operator. * src/abg-dwarf-reader.cc (build_reference_type): Ditto. * src/abg-reader.cc (read_static): Ditto. (read_is_artificial): Ditto. (build_function_parameter): Ditto. (build_function_decl): Ditto. (build_qualified_type_decl): Ditto. (build_reference_type_def): Ditto. Reviewed-by: Matthias Maennich Signed-off-by: Giuliano Procida --- src/abg-corpus.cc | 4 ++-- src/abg-dwarf-reader.cc | 2 +- src/abg-reader.cc | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/abg-corpus.cc b/src/abg-corpus.cc index ebdf8f29..147737d2 100644 --- a/src/abg-corpus.cc +++ b/src/abg-corpus.cc @@ -377,7 +377,7 @@ corpus::priv::build_unreferenced_symbols_tables() string sym_id = (*s)->get_id_string(); if (refed_funs.find(sym_id) == refed_funs.end()) { - bool keep = sym_id_fns_to_keep.empty() ? true : false; + bool keep = sym_id_fns_to_keep.empty(); for (vector::const_iterator i = sym_id_fns_to_keep.begin(); i != sym_id_fns_to_keep.end(); @@ -416,7 +416,7 @@ corpus::priv::build_unreferenced_symbols_tables() string sym_id = (*s)->get_id_string(); if (refed_vars.find(sym_id) == refed_vars.end()) { - bool keep = sym_id_vars_to_keep.empty() ? true : false; + bool keep = sym_id_vars_to_keep.empty(); for (vector::const_iterator i = sym_id_vars_to_keep.begin(); i != sym_id_vars_to_keep.end(); diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 8cbf0046..63837554 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -14779,7 +14779,7 @@ build_reference_type(read_context& ctxt, // of the current translation unit. ABG_ASSERT((size_t) ctxt.cur_transl_unit()->get_address_size() == size); - bool is_lvalue = (tag == DW_TAG_reference_type) ? true : false; + bool is_lvalue = tag == DW_TAG_reference_type; result.reset(new reference_type_def(utype, is_lvalue, size, /*alignment=*/0, diff --git a/src/abg-reader.cc b/src/abg-reader.cc index 2e31f320..47ac6229 100644 --- a/src/abg-reader.cc +++ b/src/abg-reader.cc @@ -2442,7 +2442,7 @@ read_static(xmlNodePtr node, bool& is_static) if (xml_char_sptr s = XML_NODE_GET_ATTRIBUTE(node, "static")) { string b = CHAR_STR(s); - is_static = (b == "yes") ? true : false; + is_static = b == "yes"; return true; } return false; @@ -2567,7 +2567,7 @@ read_is_artificial(xmlNodePtr node, bool& is_artificial) if (xml_char_sptr s = XML_NODE_GET_ATTRIBUTE(node, "is-artificial")) { string is_artificial_str = CHAR_STR(s) ? CHAR_STR(s) : ""; - is_artificial = (is_artificial_str == "yes") ? true : false; + is_artificial = is_artificial_str == "yes"; return true; } return false; @@ -3071,7 +3071,7 @@ build_function_parameter(read_context& ctxt, const xmlNodePtr node) xml::build_sptr(xmlGetProp(node, BAD_CAST("is-variadic")))) { is_variadic_str = CHAR_STR(s) ? CHAR_STR(s) : ""; - is_variadic = (is_variadic_str == "yes") ? true : false; + is_variadic = is_variadic_str == "yes"; } bool is_artificial = false; @@ -3146,7 +3146,7 @@ build_function_decl(read_context& ctxt, string inline_prop; if (xml_char_sptr s = XML_NODE_GET_ATTRIBUTE(node, "declared-inline")) inline_prop = CHAR_STR(s); - bool declared_inline = inline_prop == "yes" ? true : false; + bool declared_inline = inline_prop == "yes"; decl_base::visibility vis = decl_base::VISIBILITY_NONE; read_visibility(node, vis); @@ -3583,17 +3583,17 @@ build_qualified_type_decl(read_context& ctxt, string const_str; if (xml_char_sptr s = XML_NODE_GET_ATTRIBUTE(node, "const")) const_str = CHAR_STR(s); - bool const_cv = const_str == "yes" ? true : false; + bool const_cv = const_str == "yes"; string volatile_str; if (xml_char_sptr s = XML_NODE_GET_ATTRIBUTE(node, "volatile")) volatile_str = CHAR_STR(s); - bool volatile_cv = volatile_str == "yes" ? true : false; + bool volatile_cv = volatile_str == "yes"; string restrict_str; if (xml_char_sptr s = XML_NODE_GET_ATTRIBUTE(node, "restrict")) restrict_str = CHAR_STR(s); - bool restrict_cv = restrict_str == "yes" ? true : false; + bool restrict_cv = restrict_str == "yes"; qualified_type_def::CV cv = qualified_type_def::CV_NONE; if (const_cv) @@ -3743,7 +3743,7 @@ build_reference_type_def(read_context& ctxt, string kind; if (xml_char_sptr s = XML_NODE_GET_ATTRIBUTE(node, "kind")) kind = CHAR_STR(s); // this should be either "lvalue" or "rvalue". - bool is_lvalue = kind == "lvalue" ? true : false; + bool is_lvalue = kind == "lvalue"; string type_id; if (xml_char_sptr s = XML_NODE_GET_ATTRIBUTE(node, "type-id")) From patchwork Fri May 1 15:51:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 39193 From: gprocida@google.com (Giuliano Procida) Date: Fri, 1 May 2020 16:51:47 +0100 Subject: [PATCH v2 4/5] Make set_drops_artifact_from_ir non-const. In-Reply-To: <20200501155148.98623-1-gprocida@google.com> References: <20200429175133.19814-1-gprocida@google.com> <20200501155148.98623-1-gprocida@google.com> Message-ID: <20200501155148.98623-5-gprocida@google.com> Setters should be non-const but set_drops_artifact_from_ir isn't. This patch fixes this. This reason this didn't cause a compilation failure is that const shared_ptr is equivalent to X *const, not const X*. Note that resolving the apparent const-safety issue will require std::experimental::propagate_const or similar. * include/abg-suppression.h (suppression_base::set_drops_artifact_from_ir): Drop const qualifier. * src/abg-suppression.cc (suppression_base::set_drops_artifact_from_ir): Drop const qualifier. Reviewed-by: Matthias Maennich Signed-off-by: Giuliano Procida --- include/abg-suppression.h | 2 +- src/abg-suppression.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/abg-suppression.h b/include/abg-suppression.h index 4f1fb417..6383b932 100644 --- a/include/abg-suppression.h +++ b/include/abg-suppression.h @@ -71,7 +71,7 @@ public: get_drops_artifact_from_ir() const; void - set_drops_artifact_from_ir(bool) const; + set_drops_artifact_from_ir(bool); bool get_is_artificial() const; diff --git a/src/abg-suppression.cc b/src/abg-suppression.cc index ab67f40a..6d9a0f5f 100644 --- a/src/abg-suppression.cc +++ b/src/abg-suppression.cc @@ -96,7 +96,7 @@ suppression_base::get_drops_artifact_from_ir() const /// specification is to avoid adding the matched ABI artifact to the /// internal representation. void -suppression_base::set_drops_artifact_from_ir(bool f) const +suppression_base::set_drops_artifact_from_ir(bool f) {priv_->drops_artifact_ = f;} /// Test is the suppression specification is artificial. From patchwork Fri May 1 15:51:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 39194 From: gprocida@google.com (Giuliano Procida) Date: Fri, 1 May 2020 16:51:48 +0100 Subject: [PATCH v2 5/5] Hoist some common expressions evaluating offsets. In-Reply-To: <20200501155148.98623-1-gprocida@google.com> References: <20200429175133.19814-1-gprocida@google.com> <20200501155148.98623-1-gprocida@google.com> Message-ID: <20200501155148.98623-6-gprocida@google.com> This is for readability. * src/abg-suppression.cc (type_suppression::suppresses_diff): Hoist some constant expressions out of loops. Reviewed-by: Matthias Maennich Signed-off-by: Giuliano Procida --- src/abg-suppression.cc | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/abg-suppression.cc b/src/abg-suppression.cc index 6d9a0f5f..3b02182d 100644 --- a/src/abg-suppression.cc +++ b/src/abg-suppression.cc @@ -770,6 +770,11 @@ type_suppression::suppresses_diff(const diff* diff) const && (klass_diff->first_class_decl()->get_size_in_bits() <= klass_diff->second_class_decl()->get_size_in_bits())) { + const class_decl_sptr& first_type_decl = klass_diff->first_class_decl(); + const class_decl_sptr& second_type_decl = klass_diff->second_class_decl(); + size_t first_type_size = first_type_decl->get_size_in_bits(); + size_t second_type_size = second_type_decl->get_size_in_bits(); + for (string_decl_base_sptr_map::const_iterator m = klass_diff->inserted_data_members().begin(); m != klass_diff->inserted_data_members().end(); @@ -777,10 +782,6 @@ type_suppression::suppresses_diff(const diff* diff) const { decl_base_sptr member = m->second; size_t dm_offset = get_data_member_offset(member); - size_t first_type_size = - klass_diff->first_class_decl()->get_size_in_bits(); - size_t second_type_size = - klass_diff->second_class_decl()->get_size_in_bits(); bool matched = false; for (insertion_ranges::const_iterator i = @@ -791,14 +792,10 @@ type_suppression::suppresses_diff(const diff* diff) const type_suppression::insertion_range_sptr range = *i; ssize_t range_begin_val = 0,range_end_val = 0; if (!type_suppression::insertion_range::eval_boundary - (range->begin(), - klass_diff->first_class_decl(), - range_begin_val)) + (range->begin(), first_type_decl, range_begin_val)) break; if (!type_suppression::insertion_range::eval_boundary - (range->end(), - klass_diff->first_class_decl(), - range_end_val)) + (range->end(), first_type_decl, range_end_val)) break; unsigned range_begin =