[PATCH] D27860: [LLD] Remove assert from Relocations.h

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 16 13:29:20 PST 2016


zturner created this revision.
zturner added reviewers: ruiu, joerg, silvas.
zturner added a subscriber: llvm-commits.

This is triggering the following warning:

  In file included from D:\src\llvm\tools\lld\ELF\Relocations.cpp:44:
  D:\src\llvm\tools\lld\ELF/Relocations.h(101,28):  error: comparison of constant 64 with expression of type 'lld::elf::RelExpr' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
    assert(0 <= Expr && Expr < 64 && "RelExpr is too large for 64-bit mask!");
                        ~~~~ ^ ~~
  C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt\assert.h(33,17):  note: expanded from macro 'assert'
              (!!(expression)) ||                                                              \
                  ^~~~~~~~~~

which kills my -Werror build.  Since ubsan should catch cases of values larger than 64 being passed in, it seems like the assert might not be strictly necessary.  Either way, we need some way to get rid of this warning.


https://reviews.llvm.org/D27860

Files:
  ELF/Relocations.h


Index: ELF/Relocations.h
===================================================================
--- ELF/Relocations.h
+++ ELF/Relocations.h
@@ -98,7 +98,6 @@
 // RelExpr's as a constant bit mask and test for membership with a
 // couple cheap bitwise operations.
 template <RelExpr... Exprs> bool isRelExprOneOf(RelExpr Expr) {
-  assert(0 <= Expr && Expr < 64 && "RelExpr is too large for 64-bit mask!");
   return (uint64_t(1) << Expr) & RelExprMaskBuilder<Exprs...>::build();
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27860.81788.patch
Type: text/x-patch
Size: 481 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161216/286f707e/attachment.bin>


More information about the llvm-commits mailing list