r210812 - Permit -Wswitch coverage for enumerations.

Saleem Abdulrasool compnerd at compnerd.org
Thu Jun 12 12:33:26 PDT 2014


Author: compnerd
Date: Thu Jun 12 14:33:26 2014
New Revision: 210812

URL: http://llvm.org/viewvc/llvm-project?rev=210812&view=rev
Log:
Permit -Wswitch coverage for enumerations.

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!

Modified:
    cfe/trunk/lib/Basic/DiagnosticIDs.cpp
    cfe/trunk/lib/Format/Format.cpp

Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=210812&r1=210811&r2=210812&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Thu Jun 12 14:33:26 2014
@@ -368,7 +368,6 @@ StringRef DiagnosticIDs::getDescription(
 
 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
   case diag::Severity::Fatal:
     return DiagnosticIDs::Fatal;
   }
+  llvm_unreachable("unexpected severity");
 }
 
 /// getDiagnosticLevel - Based on the way the client configured the

Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=210812&r1=210811&r2=210812&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Thu Jun 12 14:33:26 2014
@@ -272,7 +272,6 @@ const char *ParseErrorCategory::name() c
 
 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(
   case ParseError::Unsuitable:
     return "Unsuitable";
   }
+  llvm_unreachable("unexpected parse error");
 }
 
 FormatStyle getLLVMStyle() {





More information about the cfe-commits mailing list