[PATCH] D58837: [ELF] Fix GCC8 warnings about "fall through", NFCI
Jonas Hahnfeld via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 1 10:29:45 PST 2019
Hahnfeld created this revision.
Hahnfeld added reviewers: MaskRay, pcc, Bigcheese.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
This is actually a false-positive since the nested switch() handles
all possible values and returns in all cases. Make this explicit by
adding llvm_unreachable's.
Repository:
rL LLVM
https://reviews.llvm.org/D58837
Files:
llvm/lib/Object/ELF.cpp
llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
Index: llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
===================================================================
--- llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
+++ llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
@@ -113,6 +113,7 @@
case RT64_8:
return IsPCRel ? ELF::R_X86_64_PC8 : ELF::R_X86_64_8;
}
+ llvm_unreachable("Previous switch() should have return'ed!");
case MCSymbolRefExpr::VK_GOT:
switch (Type) {
case RT64_64:
@@ -124,6 +125,7 @@
case RT64_8:
llvm_unreachable("Unimplemented");
}
+ llvm_unreachable("Previous switch() should have return'ed!");
case MCSymbolRefExpr::VK_GOTOFF:
assert(Type == RT64_64);
assert(!IsPCRel);
@@ -140,6 +142,7 @@
case RT64_8:
llvm_unreachable("Unimplemented");
}
+ llvm_unreachable("Previous switch() should have return'ed!");
case MCSymbolRefExpr::VK_DTPOFF:
assert(!IsPCRel);
switch (Type) {
@@ -152,6 +155,7 @@
case RT64_8:
llvm_unreachable("Unimplemented");
}
+ llvm_unreachable("Previous switch() should have return'ed!");
case MCSymbolRefExpr::VK_SIZE:
assert(!IsPCRel);
switch (Type) {
@@ -164,6 +168,7 @@
case RT64_8:
llvm_unreachable("Unimplemented");
}
+ llvm_unreachable("Previous switch() should have return'ed!");
case MCSymbolRefExpr::VK_TLSCALL:
return ELF::R_X86_64_TLSDESC_CALL;
case MCSymbolRefExpr::VK_TLSDESC:
@@ -196,6 +201,7 @@
case X86::reloc_riprel_4byte_movq_load:
return ELF::R_X86_64_REX_GOTPCRELX;
}
+ llvm_unreachable("Previous switch() should have return'ed!");
}
}
@@ -233,6 +239,7 @@
case RT32_8:
return IsPCRel ? ELF::R_386_PC8 : ELF::R_386_8;
}
+ llvm_unreachable("Previous switch() should have return'ed!");
case MCSymbolRefExpr::VK_GOT:
assert(Type == RT32_32);
if (IsPCRel)
Index: llvm/lib/Object/ELF.cpp
===================================================================
--- llvm/lib/Object/ELF.cpp
+++ llvm/lib/Object/ELF.cpp
@@ -438,6 +438,7 @@
#include "llvm/BinaryFormat/DynamicTags.def"
#undef HEXAGON_DYNAMIC_TAG
}
+ llvm_unreachable("Previous switch() should have return'ed!");
case ELF::EM_MIPS:
switch (Type) {
@@ -445,6 +446,7 @@
#include "llvm/BinaryFormat/DynamicTags.def"
#undef MIPS_DYNAMIC_TAG
}
+ llvm_unreachable("Previous switch() should have return'ed!");
case ELF::EM_PPC64:
switch (Type) {
@@ -452,6 +454,7 @@
#include "llvm/BinaryFormat/DynamicTags.def"
#undef PPC64_DYNAMIC_TAG
}
+ llvm_unreachable("Previous switch() should have return'ed!");
}
#undef DYNAMIC_TAG
switch (Type) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58837.188939.patch
Type: text/x-patch
Size: 2703 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190301/e5785f45/attachment.bin>
More information about the llvm-commits
mailing list