[lld] r345882 - Fix clang -Wimplicit-fallthrough warnings across llvm, NFC

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 1 12:54:46 PDT 2018


Author: rnk
Date: Thu Nov  1 12:54:45 2018
New Revision: 345882

URL: http://llvm.org/viewvc/llvm-project?rev=345882&view=rev
Log:
Fix clang -Wimplicit-fallthrough warnings across llvm, NFC

This patch should not introduce any behavior changes. It consists of
mostly one of two changes:
1. Replacing fall through comments with the LLVM_FALLTHROUGH macro
2. Inserting 'break' before falling through into a case block consisting
   of only 'break'.

We were already using this warning with GCC, but its warning behaves
slightly differently. In this patch, the following differences are
relevant:
1. GCC recognizes comments that say "fall through" as annotations, clang
   doesn't
2. GCC doesn't warn on "case N: foo(); default: break;", clang does
3. GCC doesn't warn when the case contains a switch, but falls through
   the outer case.

I will enable the warning separately in a follow-up patch so that it can
be cleanly reverted if necessary.

Reviewers: alexfh, rsmith, lattner, rtrieu, EricWF, bollu

Differential Revision: https://reviews.llvm.org/D53950

Modified:
    lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
    lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp

Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp?rev=345882&r1=345881&r2=345882&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp Thu Nov  1 12:54:45 2018
@@ -80,6 +80,7 @@ public:
     switch (ref->kindValue()) {
     case ripRel32Got:
       assert(targetNowGOT && "target must be GOT");
+      LLVM_FALLTHROUGH;
     case ripRel32GotLoad:
       const_cast<Reference *>(ref)
         ->setKindValue(targetNowGOT ? ripRel32 : ripRel32GotLoadNowLea);

Modified: lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp?rev=345882&r1=345881&r2=345882&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp Thu Nov  1 12:54:45 2018
@@ -262,6 +262,7 @@ void MachOLinkingContext::configure(Head
   case llvm::MachO::MH_OBJECT:
     _printRemainingUndefines = false;
     _allowRemainingUndefines = true;
+    break;
   default:
     break;
   }




More information about the llvm-commits mailing list