aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYao Qi <yao.qi@linaro.org>2017-03-22 12:35:31 +0000
committerYao Qi <yao.qi@linaro.org>2017-03-22 12:35:31 +0000
commitffdbe8642e74527795b695988a176f0920d58f96 (patch)
tree3bda2f4d3c3d0e7adc3e6ce77ebfb5af27165059
parent9d736fbf01d20bc03804fa0cb49d99fdf6628fab (diff)
downloadfsf-binutils-gdb-ffdbe8642e74527795b695988a176f0920d58f96.zip
fsf-binutils-gdb-ffdbe8642e74527795b695988a176f0920d58f96.tar.gz
fsf-binutils-gdb-ffdbe8642e74527795b695988a176f0920d58f96.tar.bz2
Wrap locally used classes in anonymous namespace
Both aarch64-tdep.c and arm-tdep.c defines a class instruction_reader, which violates ODR, but linker doesn't an emit error. I fix this issue by wrapping them by anonymous namespace, but I think it is better to apply this for all locally used classes. If it is a good idea to put locally used class into anonymous namespace, we should document this rule into GDB coding convention, or even GCC coding convention. Note that anonymous namespace has been used in GCC but GCC coding convention doesn't mention the it. gdb: 2017-03-22 Yao Qi <yao.qi@linaro.org> * aarch64-tdep.c: Wrap locally used classes in anonymous namespace. * arm-tdep.c: Likewise. * linespec.c: Likewise. * ui-out.c: Likewise.
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/aarch64-tdep.c4
-rw-r--r--gdb/arm-tdep.c3
-rw-r--r--gdb/linespec.c8
-rw-r--r--gdb/ui-out.c4
5 files changed, 27 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 547e20e..a621048 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2017-03-22 Yao Qi <yao.qi@linaro.org>
+
+ * aarch64-tdep.c: Wrap locally used classes in anonymous
+ namespace.
+ * arm-tdep.c: Likewise.
+ * linespec.c: Likewise.
+ * ui-out.c: Likewise.
+
2017-03-22 Jonah Graham <jonah@kichwacoders.com>
PR gdb/19637
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index e7d0844..f6bac37 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -196,6 +196,8 @@ show_aarch64_debug (struct ui_file *file, int from_tty,
fprintf_filtered (file, _("AArch64 debugging is %s.\n"), value);
}
+namespace {
+
/* Abstract instruction reader. */
class abstract_instruction_reader
@@ -217,6 +219,8 @@ class instruction_reader : public abstract_instruction_reader
}
};
+} // namespace
+
/* Analyze a prologue, looking for a recognizable stack frame
and frame pointer. Scan until we encounter a store that could
clobber the stack frame unexpectedly, or an unknown instruction. */
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 09f7b3a..b3c3705 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -12952,6 +12952,7 @@ thumb2_record_decode_insn_handler (insn_decode_record *thumb2_insn_r)
return -1;
}
+namespace {
/* Abstract memory reader. */
class abstract_memory_reader
@@ -12977,6 +12978,8 @@ class instruction_reader : public abstract_memory_reader
}
};
+} // namespace
+
/* Extracts arm/thumb/thumb2 insn depending on the size, and returns 0 on success
and positive val on fauilure. */
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 72bcd60..a3cb0cb 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -2793,6 +2793,8 @@ decode_objc (struct linespec_state *self, linespec_p ls, const char *arg)
return values;
}
+namespace {
+
/* A function object that serves as symbol_found_callback_ftype
callback for iterate_over_symbols. This is used by
lookup_prefix_sym to collect type symbols. */
@@ -2859,6 +2861,8 @@ decode_compound_collector::operator () (symbol *sym)
return true; /* Continue iterating. */
}
+} // namespace
+
/* Return any symbols corresponding to CLASS_NAME in FILE_SYMTABS. */
static VEC (symbolp) *
@@ -3095,6 +3099,8 @@ find_method (struct linespec_state *self, VEC (symtab_ptr) *file_symtabs,
+namespace {
+
/* This function object is a callback for iterate_over_symtabs, used
when collecting all matching symtabs. */
@@ -3148,6 +3154,8 @@ symtab_collector::operator () (struct symtab *symtab)
return false;
}
+} // namespace
+
/* Given a file name, return a VEC of all matching symtabs. If
SEARCH_PSPACE is not NULL, the search is restricted to just that
program space. */
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index 42cffbe..9c27742 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -30,6 +30,8 @@
#include <string>
#include <memory>
+namespace {
+
/* A header of a ui_out_table. */
class ui_out_hdr
@@ -91,6 +93,8 @@ class ui_out_hdr
std::string m_header;
};
+} // namespace
+
/* A level of nesting (either a list or a tuple) in a ui_out output. */
class ui_out_level