[llvm] r356035 - [RISCV] Replace incorrect use of sizeof with array_lengthof

Alex Bradbury via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 13 02:22:57 PDT 2019


Author: asb
Date: Wed Mar 13 02:22:57 2019
New Revision: 356035

URL: http://llvm.org/viewvc/llvm-project?rev=356035&view=rev
Log:
[RISCV] Replace incorrect use of sizeof with array_lengthof

RISCVDisassembler was incorrectly using sizeof(Arr) when it should have used
sizeof(Arr)/sizeof(Arr[0]). Update to use array_lengthof instead.


Modified:
    llvm/trunk/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp

Modified: llvm/trunk/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp?rev=356035&r1=356034&r2=356035&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp (original)
+++ llvm/trunk/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp Wed Mar 13 02:22:57 2019
@@ -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.




More information about the llvm-commits mailing list