Permit -Wswitch coverage for enumerations.
authorSaleem Abdulrasool <compnerd@compnerd.org>
Thu, 12 Jun 2014 19:33:26 +0000 (19:33 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Thu, 12 Jun 2014 19:33:26 +0000 (19:33 +0000)
Thanks to David Blakie and Richard Smith for pointing out that we can retain the
-Wswitch coverage while avoiding the warning from GCC by pushing the unreachable
outside of the switch!

llvm-svn: 210812

clang/lib/Basic/DiagnosticIDs.cpp
clang/lib/Format/Format.cpp

index 0b3627e..6bc230a 100644 (file)
@@ -368,7 +368,6 @@ StringRef DiagnosticIDs::getDescription(unsigned DiagID) const {
 
 static DiagnosticIDs::Level toLevel(diag::Severity SV) {
   switch (SV) {
-  default: llvm_unreachable("unexpected severity");
   case diag::Severity::Ignored:
     return DiagnosticIDs::Ignored;
   case diag::Severity::Remark:
@@ -380,6 +379,7 @@ static DiagnosticIDs::Level toLevel(diag::Severity SV) {
   case diag::Severity::Fatal:
     return DiagnosticIDs::Fatal;
   }
+  llvm_unreachable("unexpected severity");
 }
 
 /// getDiagnosticLevel - Based on the way the client configured the
index e1ec251..913c622 100644 (file)
@@ -272,7 +272,6 @@ const char *ParseErrorCategory::name() const LLVM_NOEXCEPT {
 
 std::string ParseErrorCategory::message(int EV) const {
   switch (static_cast<ParseError>(EV)) {
-  default: llvm_unreachable("unexpected parse error");
   case ParseError::Success:
     return "Success";
   case ParseError::Error:
@@ -280,6 +279,7 @@ std::string ParseErrorCategory::message(int EV) const {
   case ParseError::Unsuitable:
     return "Unsuitable";
   }
+  llvm_unreachable("unexpected parse error");
 }
 
 FormatStyle getLLVMStyle() {