]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Drop the "cat" function, use operator| instead
authorPetr Machata <pmachata@redhat.com>
Mon, 28 Mar 2011 18:19:36 +0000 (20:19 +0200)
committerPetr Machata <pmachata@redhat.com>
Mon, 28 Mar 2011 18:19:36 +0000 (20:19 +0200)
12 files changed:
dwarflint/check_debug_abbrev.cc
dwarflint/check_debug_info.cc
dwarflint/check_debug_line.cc
dwarflint/check_debug_loc_range.cc
dwarflint/check_dups_abstract_origin.cc
dwarflint/check_expected_trees.cc
dwarflint/check_matching_ranges.cc
dwarflint/check_range_out_of_scope.cc
dwarflint/check_self_referential_die.cc
dwarflint/messages.cc
dwarflint/messages.hh
dwarflint/sections.cc

index c8038c6d353db77614336376972ef80e8700a556..591c8d961faac6a231f4ab7c8ceee62993df80c4 100644 (file)
@@ -135,7 +135,7 @@ namespace
     if (ret)
       {
        where wh = WHERE (sec_abbrev, NULL);
-       wr_message (wh, cat (mc_abbrevs, mc_impact_1, mc_acc_bloat))
+       wr_message (wh, mc_abbrevs | mc_impact_1 | mc_acc_bloat)
          << "no abbreviations." << std::endl;
       }
     return ret;
@@ -446,8 +446,7 @@ namespace
            if (attrib_name == DW_AT_sibling)
              {
                if (!cur->has_children)
-                 wr_message (where,
-                             cat (mc_die_rel, mc_acc_bloat, mc_impact_1))
+                 wr_message (where, mc_die_rel | mc_acc_bloat | mc_impact_1)
                    << "superfluous DW_AT_sibling attribute at childless abbrev."
                    << std::endl;
              }
index dd0898530806d300c2694adf5b47b9d5875d3daa..453d832eadd72a11f2d60d67fde51a77866e0737 100644 (file)
@@ -157,8 +157,7 @@ namespace
               reference is valid, which it is.  But warn about this
               anyway, perhaps local reference could be formed on
               smaller number of bytes.  */
-           wr_message (ref->who,
-                       cat (mc_impact_2, mc_acc_suboptimal, mc_die_rel))
+           wr_message (ref->who, mc_impact_2 | mc_acc_suboptimal | mc_die_rel)
              << "local reference to " << pri::DIE (ref->addr)
              << " formed as global." << std::endl;
        }
@@ -194,7 +193,7 @@ namespace
        if (!read_ctx_need_data (&ctx, 4)
            && read_check_zero_padding (&ctx, &off_start, &off_end))
          {
-           wr_message_padding_0 (cat (mc_info, mc_header), &where,
+           wr_message_padding_0 (mc_info | mc_header, &where,
                                  off_start, off_end);
            break;
          }
@@ -213,7 +212,7 @@ namespace
        if (size32 == 0
            && read_check_zero_padding (&ctx, &off_start, &off_end))
          {
-           wr_message_padding_0 (cat (mc_info, mc_header), &where,
+           wr_message_padding_0 (mc_info | mc_header, &where,
                                  off_start, off_end);
            break;
          }
@@ -275,7 +274,7 @@ namespace
                                 // next time we pass by this
          }
        else if (file->ehdr.e_type == ET_REL)
-         wr_message (head.where, cat (mc_impact_2, mc_info, mc_reloc))
+         wr_message (head.where, mc_impact_2 | mc_info | mc_reloc)
            << pri::lacks_relocation ("abbrev table offset") << std::endl;
 
        /* Address size.  */
@@ -477,7 +476,7 @@ namespace
   check_rangeptr (uint64_t value, struct value_check_cb_ctx const *ctx)
   {
     if ((value % ctx->cu->head->address_size) != 0)
-      wr_message (*ctx->where, cat (mc_ranges, mc_impact_2))
+      wr_message (*ctx->where, mc_ranges | mc_impact_2)
        << "rangeptr value " << pri::hex (value)
        << " not aligned to CU address size." << std::endl;
     *ctx->need_rangesp = true;
@@ -613,8 +612,7 @@ namespace
               reason we can't simply check this when loading
               abbrevs.  */
            DEF_PREV_WHERE;
-           wr_message (prev_where, cat (mc_die_rel, mc_acc_suboptimal,
-                                        mc_impact_4))
+           wr_message (prev_where, mc_die_rel | mc_acc_suboptimal | mc_impact_4)
              << "This DIE had children, but no DW_AT_sibling attribute."
              << std::endl;
          }
@@ -880,8 +878,8 @@ namespace
                                        &where, skip_mismatched)))
              {
                if (relocate == rel_no)
-                 wr_message (where, cat (mc_impact_4, mc_die_other,
-                                         mc_reloc, extra_mc))
+                 wr_message (where, (mc_impact_4 | mc_die_other
+                                     | mc_reloc | extra_mc))
                    << "unexpected relocation of "
                    << elfutils::dwarf::forms::name (form_name)
                    << '.' << std::endl;
@@ -904,8 +902,8 @@ namespace
                    && (relocate == rel_require
                        || (relocate == rel_nonzero
                            && value != 0)))
-                 wr_message (where, cat (mc_impact_2, mc_die_other,
-                                         mc_reloc, extra_mc))
+                 wr_message (where, (mc_impact_2 | mc_die_other
+                                     | mc_reloc | extra_mc))
                    << pri::lacks_relocation
                        (elfutils::dwarf::forms::name (form_name))
                    << std::endl;
@@ -1159,7 +1157,7 @@ check_debug_info::check_debug_info (checkstack &stack, dwarflint &lint)
        /* Did we read up everything?  */
        {
          where wh = WHERE (sec_info, NULL);
-         wr_message (cat (mc_die_other, mc_impact_4), &wh,
+         wr_message (mc_die_other | mc_impact_4, &wh,
                      ": CU lengths don't exactly match Elf_Data contents.");
        }
       else
@@ -1177,7 +1175,7 @@ check_debug_info::check_debug_info (checkstack &stack, dwarflint &lint)
          for (size_t i = 0; i < it->second.size; ++i)
            if (!it->second.abbr[i].used)
              wr_message (it->second.abbr[i].where,
-                         cat (mc_impact_3, mc_acc_bloat, mc_abbrevs))
+                         mc_impact_3 | mc_acc_bloat | mc_abbrevs)
                << "abbreviation is never used." << std::endl;
     }
 
@@ -1289,7 +1287,7 @@ check_debug_info_refs::check_debug_info_refs (checkstack &stack,
 
       if (_m_aranges != NULL && !it->has_arange)
        wr_message (it->head->where,
-                   cat (mc_impact_3, mc_acc_suboptimal, mc_aranges, mc_info))
+                   mc_impact_3 | mc_acc_suboptimal | mc_aranges | mc_info)
          << "no aranges table is associated with this CU." << std::endl;
     }
 }
index 77ee6ebecc594123cd89bf380b82e6791ddaf3b8..b9d450f7914c1f84bc0f5fd9306b8772b6d31c93 100644 (file)
@@ -103,7 +103,7 @@ namespace
       return false;
 
     if (*name == '/' && *ptr != 0)
-      wr_message (*where, cat (mc_impact_2, mc_line, mc_header))
+      wr_message (*where, mc_impact_2 | mc_line | mc_header)
        << "file #" << nfile
        << " has absolute pathname, but refers to directory != 0."
        << std::endl;
@@ -111,7 +111,7 @@ namespace
     if (*ptr > include_directories.size ())
       /* Not >=, dirs are indexed from 1.  */
       {
-       wr_message (*where, cat (mc_impact_4, mc_line, mc_header))
+       wr_message (*where, mc_impact_4 | mc_line | mc_header)
          << "file #" << nfile
          << " refers to directory #" << *ptr
          << ", which wasn't defined." << std::endl;
@@ -228,7 +228,7 @@ check_debug_line::check_debug_line (checkstack &stack, dwarflint &lint)
         "true."  [But give a notice if it's not 0 or 1.]  */
       if (default_is_stmt != 0
          && default_is_stmt != 1)
-       wr_message (where, cat (mc_line, mc_impact_2, mc_header))
+       wr_message (where, mc_line | mc_impact_2 | mc_header)
          << "default_is_stmt should be 0 or 1, not "
          << default_is_stmt << '.' << std::endl;
 
@@ -369,10 +369,10 @@ check_debug_line::check_debug_line (checkstack &stack, dwarflint &lint)
          struct where wh = WHERE (sec_line, NULL);
          uint64_t off_start, off_end;
          if (read_check_zero_padding (&sub_ctx, &off_start, &off_end))
-           wr_message_padding_0 (cat (mc_line, mc_header), &wh,
+           wr_message_padding_0 (mc_line | mc_header, &wh,
                                  off_start, off_end);
          else
-           wr_message_padding_n0 (cat (mc_line, mc_header), &wh,
+           wr_message_padding_n0 (mc_line | mc_header, &wh,
                                   off_start, program_start - sub_ctx.begin);
          sub_ctx.ptr = program_start;
        }
@@ -489,7 +489,7 @@ check_debug_line::check_debug_line (checkstack &stack, dwarflint &lint)
 #undef ONE_KNOWN_DW_LNE
                      default:
                        /* No we don't, emit a warning.  */
-                       wr_message (where, cat (mc_impact_2, mc_line))
+                       wr_message (where, mc_impact_2 | mc_line)
                          << "unknown extended opcode #" << extended
                          << '.' << std::endl;
                      };
@@ -577,7 +577,7 @@ check_debug_line::check_debug_line (checkstack &stack, dwarflint &lint)
 
                default:
                  if (opcode < opcode_base)
-                   wr_message (where, cat (mc_impact_2, mc_line))
+                   wr_message (where, mc_impact_2 | mc_line)
                      << "unknown standard opcode #" << opcode
                      << '.' << std::endl;
                };
@@ -612,7 +612,7 @@ check_debug_line::check_debug_line (checkstack &stack, dwarflint &lint)
       for (size_t i = 0; i < include_directories.size (); ++i)
        if (!include_directories[i].used)
          wr_message (where,
-                     cat (mc_impact_3, mc_acc_bloat, mc_line, mc_header))
+                     mc_impact_3 | mc_acc_bloat | mc_line | mc_header)
            << "the include #" << i + 1
            << " `" << include_directories[i].name
            << "' is not used." << std::endl;
@@ -626,14 +626,14 @@ check_debug_line::check_debug_line (checkstack &stack, dwarflint &lint)
          for (size_t i = 0; i < files.size (); ++i)
            if (!files[i].used)
              wr_message (where,
-                         cat (mc_impact_3, mc_acc_bloat, mc_line, mc_header))
+                         mc_impact_3 | mc_acc_bloat | mc_line | mc_header)
                << "the file #" << i + 1
                << " `" << files[i].name << "' is not used." << std::endl;
            else
              useful = true;
 
          if (!seen_opcode && !useful)
-           wr_message (where, cat (mc_line, mc_acc_bloat, mc_impact_3))
+           wr_message (where, mc_line | mc_acc_bloat | mc_impact_3)
              << "empty line number program and no references from .debug_info."
              << std::endl;
        }
index 751d54f1a26ae909c764a2a0ce221bcb4e4c7758..cdd696062e113c5f0e7f6f3e741c669c98b31c51 100644 (file)
@@ -890,7 +890,7 @@ check_location_expression (dwarf_version const *ver,
            int16_t skip = (uint16_t)value1;
 
            if (skip == 0)
-             wr_message (where, cat (mc_loc, mc_acc_bloat, mc_impact_3))
+             wr_message (where, mc_loc | mc_acc_bloat | mc_impact_3)
                << elfutils::dwarf::ops::name (opcode)
                << " with skip 0." << std::endl;
            else if (skip > 0 && !read_ctx_need_data (&ctx, (size_t)skip))
@@ -927,7 +927,7 @@ check_location_expression (dwarf_version const *ver,
                  || opcode == DW_OP_deref_size
                  || opcode == DW_OP_plus_uconst)
              && (value1 > (uint64_t)(uint32_t)-1))
-           wr_message (where, cat (mc_loc, mc_acc_bloat, mc_impact_3))
+           wr_message (where, mc_loc | mc_acc_bloat | mc_impact_3)
              << elfutils::dwarf::ops::name (opcode)
              << " with operand " << pri::hex (value1)
              << " on a 32-bit machine." << std::endl;
index 9bcef17b982d8b41049a704254275ba0af034d8f..3142ba1e7f3494fe6b7c0a2c824127be5a6b7e1b 100644 (file)
@@ -73,8 +73,7 @@ namespace
             at = referree.attributes ().begin ();
           at != referree.attributes ().end (); ++at)
        if ((at2 = m.find ((*at).first)) != m.end ())
-         wr_message (to_where (die),
-                     cat (mc_impact_3, mc_acc_bloat, mc_die_rel))
+         wr_message (to_where (die), mc_impact_3 | mc_acc_bloat | mc_die_rel)
            << "Attribute " << dwarf::attributes::name (at2->first)
            << " is duplicated at " << dwarf::attributes::name (attr.first)
            << " (" << pri::ref (referree) << ")"
index f3eaae10a821046792c2211c9f09b13e4815b6d5..ab91a712575ffd714083a07a606de6492abd17c4 100644 (file)
@@ -138,7 +138,7 @@ check_expected_trees::check_expected_trees (checkstack &stack, dwarflint &lint)
                  case opt_expected:
                    if (what == NULL)
                      what = " should contain attribute ";
-                   wr_message (where, cat (mc_impact_2, mc_info))
+                   wr_message (where, mc_impact_2 | mc_info)
                      << elfutils::dwarf::tags::name (parent_tag) << what
                      << elfutils::dwarf::attributes::name (jt->first) << '.'
                      << std::endl;
@@ -161,7 +161,7 @@ check_expected_trees::check_expected_trees (checkstack &stack, dwarflint &lint)
              expected_set::expectation_map::const_iterator
                kt = expect.find (name);
              if (kt == expect.end ())
-               wr_message (where, cat (mc_impact_3, mc_info))
+               wr_message (where, mc_impact_3 | mc_info)
                  << ": DIE \"" << dwarf::tags::name (parent_tag)
                  << "\" has attribute \"" << dwarf::attributes::name (name)
                  << "\", which is not expected." << std::endl;
@@ -171,7 +171,7 @@ check_expected_trees::check_expected_trees (checkstack &stack, dwarflint &lint)
                  unsigned exp_vs = expected_value_space (name, parent_tag);
                  dwarf::value_space vs = (*jt).second.what_space ();
                  if ((exp_vs & (1U << vs)) == 0)
-                   wr_message (where, cat (mc_impact_3, mc_info))
+                   wr_message (where, mc_impact_3 | mc_info)
                      << ": in DIE \"" << dwarf::tags::name (parent_tag)
                      << "\", attribute \"" << dwarf::attributes::name (name)
                      << "\" has value of unexpected type \"" << vs
@@ -180,7 +180,7 @@ check_expected_trees::check_expected_trees (checkstack &stack, dwarflint &lint)
              // XXX more specific class when <dwarf> has it
              catch (...)
                {
-                 wr_message (where, cat (mc_impact_4, mc_info, mc_error))
+                 wr_message (where, mc_impact_4 | mc_info | mc_error)
                    << ": in DIE \"" << dwarf::tags::name (parent_tag)
                    << "\", couldn't obtain type of attribute \""
                    << dwarf::attributes::name (name) << "\"."
index f9c0596206ea70c5188867783cc980506d1cee7c..af46ffffea1339c1415538cd43678ec217e00a34 100644 (file)
@@ -94,7 +94,7 @@ check_matching_ranges::check_matching_ranges (checkstack &stack,
 
          for (range_vec::iterator it = missing.begin ();
               it != missing.end (); ++it)
-           wr_message (cat (mc_ranges, mc_aranges, mc_impact_3), &where_r,
+           wr_message (mc_ranges | mc_aranges | mc_impact_3, &where_r,
                        ": missing range %s, present in .debug_aranges.\n",
                        range_fmt (buf, sizeof buf, it->first, it->second));
 
@@ -105,7 +105,7 @@ check_matching_ranges::check_matching_ranges (checkstack &stack,
 
          for (range_vec::iterator it = missing.begin ();
               it != missing.end (); ++it)
-           wr_message (cat (mc_ranges, mc_aranges, mc_impact_3), &where_ar,
+           wr_message (mc_ranges | mc_aranges | mc_impact_3, &where_ar,
                        ": missing range %s, present in .debug_ranges.\n",
                        range_fmt (buf, sizeof buf, it->first, it->second));
        }
index 05d914a9a7ae29875257f804fcee82904d647dee..016cb38acbb781fcfad15ace18286e3de082c3cb 100644 (file)
@@ -137,7 +137,7 @@ check_range_out_of_scope::recursively_validate
       if (high_pc != ::noaddr)
        {
          if (my_ranges.size () != 0)
-           wr_message (wh, cat (mc_impact_4, mc_info, mc_error))
+           wr_message (wh, mc_impact_4 | mc_info | mc_error)
              << "both low_pc/high_pc pair and ranges present."
              << std::endl;
          else
index 1f1dfe8f63494998c11095ef1f6390ace654c802..196193b65546ddc320a5704a8ebcff0e6816059e 100644 (file)
@@ -71,9 +71,8 @@ namespace
                {
                  dwarf::debug_info_entry ref = *val.reference ();
                  if (ref.identity () == die.identity ())
-                   wr_message (to_where (die), cat (mc_impact_3,
-                                                    mc_acc_suboptimal,
-                                                    mc_die_rel))
+                   wr_message (to_where (die),
+                               mc_impact_3 | mc_acc_suboptimal | mc_die_rel)
                      << "attribute " << dwarf::attributes::name ((*at).first)
                      << " references DIE itself." << std::endl;
                }
index 28b8d20c5b524b735bdff92cbefa083a42f7f12a..b8e8f768cc473f5c1053cf1bb902393d15e4bd6a 100644 (file)
@@ -137,8 +137,8 @@ message_criteria::operator &= (message_term const &term)
   for (size_t i = 0; i < size (); )
     {
       message_term &t = at (i);
-      t.positive = cat (t.positive, term.positive);
-      t.negative = cat (t.negative, term.negative);
+      t.positive = t.positive | term.positive;
+      t.negative = t.negative | term.negative;
       if ((t.positive & t.negative) != 0)
        /* A ^ ~A -> drop the term.  */
        erase (begin () + i);
index 7809fb9cb43db7b0893ea38de250797411f00298..49dbd925fbda490a11096a3f012752ae939829a9 100644 (file)
@@ -153,15 +153,6 @@ extern struct message_criteria warning_criteria;
 /* Accepted (warning) messages, that are turned into errors.  */
 extern struct message_criteria error_criteria;
 
-inline message_category
-cat (message_category c1,
-     message_category c2,
-     message_category c3 = mc_none,
-     message_category c4 = mc_none)
-{
-  return c1 | c2 | c3 | c4;
-}
-
 std::ostream &wr_warning (where const &wh);
 std::ostream &wr_warning ();
 std::ostream &wr_error (where const &wh);
index a9b2f0cec71e6d40e606f01eb7c939582f9a06f2..f9a64b08a0e6e713cd1d424b2c71832d5a59784c 100644 (file)
@@ -397,7 +397,7 @@ namespace
 
        if (secentry *str = secinfo.get (".debug_str"))
          if (str->reldata != NULL)
-           wr_message (WHERE (sec_str, NULL), cat (mc_impact_2, mc_elf))
+           wr_message (WHERE (sec_str, NULL), mc_impact_2 | mc_elf)
              << "there's a relocation section associated with this section."
              << std::endl;
       }