]> granicus.if.org Git - llvm/commitdiff
[RISCV] Replace incorrect use of sizeof with array_lengthof
authorAlex Bradbury <asb@lowrisc.org>
Wed, 13 Mar 2019 09:22:57 +0000 (09:22 +0000)
committerAlex Bradbury <asb@lowrisc.org>
Wed, 13 Mar 2019 09:22:57 +0000 (09:22 +0000)
RISCVDisassembler was incorrectly using sizeof(Arr) when it should have used
sizeof(Arr)/sizeof(Arr[0]). Update to use array_lengthof instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356035 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp

index a300de6ca04c4c5b70695a97cc513c743f6990e7..26d5bca8de250f9d1a1129065a2d26c3b4ddb50f 100644 (file)
@@ -69,7 +69,7 @@ static const unsigned GPRDecoderTable[] = {
 static DecodeStatus DecodeGPRRegisterClass(MCInst &Inst, uint64_t RegNo,
                                            uint64_t Address,
                                            const void *Decoder) {
-  if (RegNo > sizeof(GPRDecoderTable))
+  if (RegNo > array_lengthof(GPRDecoderTable))
     return MCDisassembler::Fail;
 
   // We must define our own mapping from RegNo to register identifier.
@@ -94,7 +94,7 @@ static const unsigned FPR32DecoderTable[] = {
 static DecodeStatus DecodeFPR32RegisterClass(MCInst &Inst, uint64_t RegNo,
                                              uint64_t Address,
                                              const void *Decoder) {
-  if (RegNo > sizeof(FPR32DecoderTable))
+  if (RegNo > array_lengthof(FPR32DecoderTable))
     return MCDisassembler::Fail;
 
   // We must define our own mapping from RegNo to register identifier.
@@ -130,7 +130,7 @@ static const unsigned FPR64DecoderTable[] = {
 static DecodeStatus DecodeFPR64RegisterClass(MCInst &Inst, uint64_t RegNo,
                                              uint64_t Address,
                                              const void *Decoder) {
-  if (RegNo > sizeof(FPR64DecoderTable))
+  if (RegNo > array_lengthof(FPR64DecoderTable))
     return MCDisassembler::Fail;
 
   // We must define our own mapping from RegNo to register identifier.