diff options
| author | Alexander Richardson <arichardson.kde@gmail.com> | 2018-03-27 10:08:12 +0000 |
|---|---|---|
| committer | Alexander Richardson <arichardson.kde@gmail.com> | 2018-03-27 10:08:12 +0000 |
| commit | e8059b1de44ff96530d151515123a28048c59833 (patch) | |
| tree | 2224b96066df372f38ee102f62748c8826d2d61c /llvm | |
| parent | b1ad66ff12991ac4ef464de2540199f784cbcffd (diff) | |
| download | bcm5719-llvm-e8059b1de44ff96530d151515123a28048c59833.tar.gz bcm5719-llvm-e8059b1de44ff96530d151515123a28048c59833.zip | |
[MIPS] Add static_assert that all Fixups are handled in getFixupKind
Summary:
I recently added a new Fixup kind to our fork of LLVM but forgot to add
it to the table in MipsAsmBackend.cpp. With this static_assert the error
would have been caught instead of zero-initializing the array entries for
the new fixups.
Reviewers: sdardis, atanasyan
Reviewed By: atanasyan
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D44895
llvm-svn: 328616
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp index acbc6d37e24..6a6e76c79ca 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp @@ -16,6 +16,7 @@ #include "MCTargetDesc/MipsFixupKinds.h" #include "MCTargetDesc/MipsMCExpr.h" #include "MCTargetDesc/MipsMCTargetDesc.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/MC/MCAsmBackend.h" #include "llvm/MC/MCAssembler.h" #include "llvm/MC/MCContext.h" @@ -303,7 +304,7 @@ Optional<MCFixupKind> MipsAsmBackend::getFixupKind(StringRef Name) const { const MCFixupKindInfo &MipsAsmBackend:: getFixupKindInfo(MCFixupKind Kind) const { - const static MCFixupKindInfo LittleEndianInfos[Mips::NumTargetFixupKinds] = { + const static MCFixupKindInfo LittleEndianInfos[] = { // This table *must* be in same the order of fixup_* kinds in // MipsFixupKinds.h. // @@ -374,8 +375,10 @@ getFixupKindInfo(MCFixupKind Kind) const { { "fixup_Mips_SUB", 0, 64, 0 }, { "fixup_MICROMIPS_SUB", 0, 64, 0 } }; + static_assert(array_lengthof(LittleEndianInfos) == Mips::NumTargetFixupKinds, + "Not all MIPS little endian fixup kinds added!"); - const static MCFixupKindInfo BigEndianInfos[Mips::NumTargetFixupKinds] = { + const static MCFixupKindInfo BigEndianInfos[] = { // This table *must* be in same the order of fixup_* kinds in // MipsFixupKinds.h. // @@ -446,6 +449,8 @@ getFixupKindInfo(MCFixupKind Kind) const { { "fixup_Mips_SUB", 0, 64, 0 }, { "fixup_MICROMIPS_SUB", 0, 64, 0 } }; + static_assert(array_lengthof(BigEndianInfos) == Mips::NumTargetFixupKinds, + "Not all MIPS big endian fixup kinds added!"); if (Kind < FirstTargetFixupKind) return MCAsmBackend::getFixupKindInfo(Kind); |

