binutils-gdb/gdb/common
Simon Marchi b020ff8074 Introduce in_inclusive_range, fix -Wtautological-compare warnings
When compiling with clang or gcc 8, we see warnings like this:

/home/emaisin/src/binutils-gdb/gdb/arm-tdep.c:10013:13: error: comparison of 0 <= unsigned expression is always true [-Werror,-Wtautological-compare]
      if (0 <= insn_op1 && 3 >= insn_op1)
          ~ ^  ~~~~~~~~
/home/emaisin/src/binutils-gdb/gdb/arm-tdep.c:11722:20: error: comparison of unsigned expression >= 0 is always true [-Werror,-Wtautological-compare]
      else if (opB >= 0 && opB <= 2)
               ~~~ ^  ~

This is because an unsigned integer (opB in this case) will always be >=
0.  It is still useful to keep both bounds of the range in the
expression, even if one is at the edge of the data type range.  This
patch introduces a utility function in_inclusive_range that gets rid of
the warning while conveying that we are checking for a range.

Tested by rebuilding.

gdb/ChangeLog:

	* common/common-utils.h (in_inclusive_range): New function.
	* arm-tdep.c (arm_record_extension_space): Use
	in_inclusive_range.
	(thumb_record_ld_st_reg_offset): Use in_inclusive_range.
	* cris-tdep.c (cris_spec_reg_applicable): Use
	in_inclusive_range.
2017-10-30 14:27:38 -04:00
..
agent.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
agent.h Add STRINGIFY to gdb/common/preprocessor.h 2017-06-22 10:59:42 +01:00
array-view.h Introduce gdb::array_view 2017-09-04 17:10:12 +01:00
ax.def update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
break-common.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
btrace-common.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
btrace-common.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
buffer.c Make xml_escape_text return an std::string 2017-09-16 14:19:31 +02:00
buffer.h buffer.h: Fix spelling mistakes 2017-07-03 13:59:00 +02:00
byte-vector.h Introduce gdb::byte_vector, add allocator that default-initializes 2017-06-14 11:08:52 +01:00
cleanups.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
cleanups.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-debug.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-debug.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-defs.h Poison non-POD memset & non-trivially-copyable memcpy/memmove 2017-04-25 01:46:19 +01:00
common-exceptions.c Eliminate catch_errors 2017-10-10 16:45:50 +01:00
common-exceptions.h Eliminate catch_exceptions/catch_exceptions_with_msg 2017-10-10 17:01:25 +01:00
common-gdbthread.h Share parts of gdb/gdbthread.h with gdbserver 2017-06-07 19:56:01 -04:00
common-inferior.h Extend "set cwd" to work on gdbserver 2017-10-04 02:01:45 -04:00
common-regcache.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-regcache.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-types.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common-utils.c Introduce string_appendf/string_vappendf 2017-10-30 11:41:34 +00:00
common-utils.h Introduce in_inclusive_range, fix -Wtautological-compare warnings 2017-10-30 14:27:38 -04:00
common.host update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
common.m4 Create gdb_termios.h (and cleanup gdb/{,gdbserver/}terminal.h) 2017-04-12 17:59:45 -04:00
create-version.sh update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
def-vector.h Introduce gdb::byte_vector, add allocator that default-initializes 2017-06-14 11:08:52 +01:00
default-init-alloc.h Introduce gdb::byte_vector, add allocator that default-initializes 2017-06-14 11:08:52 +01:00
diagnostics.h vec: Silence -Wunused-function warnings on clang 2017-06-26 16:51:17 +02:00
enum-flags.h Don't memcpy non-trivially-copyable types: Make enum_flags triv. copyable 2017-04-25 01:42:03 +01:00
environ.c Implement the ability to set/unset environment variables to GDBserver when starting the inferior 2017-08-31 17:22:10 -04:00
environ.h Implement the ability to set/unset environment variables to GDBserver when starting the inferior 2017-08-31 17:22:10 -04:00
errors.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
errors.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
fileio.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
fileio.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
filestuff.c Introduce and use gdb_file_up 2017-08-03 07:58:52 -06:00
filestuff.h Introduce and use gdb_file_up 2017-08-03 07:58:52 -06:00
format.c Target FP printing: Simplify and fix ui_printf 2017-10-24 18:00:50 +02:00
format.h Target FP printing: Simplify and fix ui_printf 2017-10-24 18:00:50 +02:00
function-view.h Poison non-POD memset & non-trivially-copyable memcpy/memmove 2017-04-25 01:46:19 +01:00
gdb_assert.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_locale.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_optional.h More gdb::optional features 2017-04-18 23:48:41 +01:00
gdb_ref_ptr.h Use class to manage BFD reference counts 2017-01-10 19:14:10 -07:00
gdb_setjmp.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_signals.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_splay_tree.h Remove free_splay_tree cleanup 2017-10-09 17:39:29 -06:00
gdb_sys_time.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_termios.h Create gdb_termios.h (and cleanup gdb/{,gdbserver/}terminal.h) 2017-04-12 17:59:45 -04:00
gdb_tilde_expand.c Introduce gdb_tilde_expand 2017-10-04 01:57:29 -04:00
gdb_tilde_expand.h Introduce gdb_tilde_expand 2017-10-04 01:57:29 -04:00
gdb_unique_ptr.h Allow gdb::unique_xmalloc_ptr<T[]> 2017-08-10 14:18:02 +01:00
gdb_unlinker.h gdb: Fix ATTRIBUTE_NONNULL usage 2017-03-08 15:52:16 +00:00
gdb_vecs.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
gdb_vecs.h Remove definition of VEC (CORE_ADDR) 2017-05-02 13:30:09 -04:00
gdb_wait.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
host-defs.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
job-control.c Move parts of inferior job control to common/ 2017-06-07 19:52:56 -04:00
job-control.h Move parts of inferior job control to common/ 2017-06-07 19:52:56 -04:00
mingw-strerror.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
new-op.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
offset-type.h Make sect_offset and cu_offset strong typedefs instead of structs 2017-04-04 20:03:26 +01:00
poison.h Fix build on gcc < 5 (std::is_trivially_copyable missing) 2017-04-25 10:58:57 +01:00
posix-strerror.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
preprocessor.h Add STRINGIFY to gdb/common/preprocessor.h 2017-06-22 10:59:42 +01:00
print-utils.c -Wwrite-strings: The Rest 2017-04-05 19:21:37 +01:00
print-utils.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
ptid.c Class-ify ptid_t 2017-04-06 23:29:53 -04:00
ptid.h Class-ify ptid_t 2017-04-06 23:29:53 -04:00
queue.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
refcounted-object.h Use DISABLE_COPY_AND_ASSIGN 2017-09-19 10:10:03 +01:00
rsp-low.c Constify unpack_varlen_hex & fix fallout 2017-09-29 17:15:36 +01:00
rsp-low.h Constify unpack_varlen_hex & fix fallout 2017-09-29 17:15:36 +01:00
run-time-clock.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
run-time-clock.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
scoped_restore.h Make inferior::detaching a bool, and introduce scoped_restore::release() 2017-04-19 13:12:23 +01:00
selftest.c Add selftests run filtering 2017-09-16 14:06:03 +02:00
selftest.h Add selftests run filtering 2017-09-16 14:06:03 +02:00
signals-state-save-restore.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
signals-state-save-restore.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
signals.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
symbol.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
traits.h Fix build on gcc < 5 (std::is_trivially_copyable missing) 2017-04-25 10:58:57 +01:00
underlying.h dwarf2read.c: Make dir_index and file_name_index strong typedefs 2017-04-04 20:03:25 +01:00
valid-expr.h Make sect_offset and cu_offset strong typedefs instead of structs 2017-04-04 20:03:26 +01:00
vec.c update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
vec.h vec: Silence -Wunused-function warnings on clang 2017-06-26 16:51:17 +02:00
version.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
x86-xstate.h Add support for Intel PKRU register to GDB and GDBserver. 2017-02-17 11:44:48 +01:00
xml-utils.c Make xml_escape_text return an std::string 2017-09-16 14:19:31 +02:00
xml-utils.h Make xml_escape_text return an std::string 2017-09-16 14:19:31 +02:00