[llvm-branch-commits] [llvm] 4d7cb6d - [Sparc] SparcMCExpr::printVariantKind - fix Wcovered-switch-default gcc warning. NFCI.

Simon Pilgrim via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jan 4 06:13:54 PST 2021


Author: Simon Pilgrim
Date: 2021-01-04T14:08:44Z
New Revision: 4d7cb6da9fcf980a8ddaa09ffa2dcab1525a66db

URL: https://github.com/llvm/llvm-project/commit/4d7cb6da9fcf980a8ddaa09ffa2dcab1525a66db
DIFF: https://github.com/llvm/llvm-project/commit/4d7cb6da9fcf980a8ddaa09ffa2dcab1525a66db.diff

LOG: [Sparc] SparcMCExpr::printVariantKind - fix Wcovered-switch-default gcc warning. NFCI.

Added: 
    

Modified: 
    llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp
index 2f28a06f1573..b84ecf074455 100644
--- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp
+++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp
@@ -41,49 +41,46 @@ void SparcMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
 
 bool SparcMCExpr::printVariantKind(raw_ostream &OS, VariantKind Kind)
 {
-  bool closeParen = true;
   switch (Kind) {
-  default:
-    llvm_unreachable("Unhandled SparcMCExpr::VariantKind");
-  case VK_Sparc_None:     closeParen = false; break;
-  case VK_Sparc_LO:       OS << "%lo(";  break;
-  case VK_Sparc_HI:       OS << "%hi(";  break;
-  case VK_Sparc_H44:      OS << "%h44("; break;
-  case VK_Sparc_M44:      OS << "%m44("; break;
-  case VK_Sparc_L44:      OS << "%l44("; break;
-  case VK_Sparc_HH:       OS << "%hh(";  break;
-  case VK_Sparc_HM:       OS << "%hm(";  break;
+  case VK_Sparc_None:     return false;
+  case VK_Sparc_LO:       OS << "%lo(";  return true;
+  case VK_Sparc_HI:       OS << "%hi(";  return true;
+  case VK_Sparc_H44:      OS << "%h44("; return true;
+  case VK_Sparc_M44:      OS << "%m44("; return true;
+  case VK_Sparc_L44:      OS << "%l44("; return true;
+  case VK_Sparc_HH:       OS << "%hh(";  return true;
+  case VK_Sparc_HM:       OS << "%hm(";  return true;
     // FIXME: use %pc22/%pc10, if system assembler supports them.
-  case VK_Sparc_PC22:     OS << "%hi("; break;
-  case VK_Sparc_PC10:     OS << "%lo("; break;
+  case VK_Sparc_PC22:     OS << "%hi("; return true;
+  case VK_Sparc_PC10:     OS << "%lo("; return true;
     // FIXME: use %got22/%got10, if system assembler supports them.
-  case VK_Sparc_GOT22:    OS << "%hi("; break;
-  case VK_Sparc_GOT10:    OS << "%lo("; break;
-  case VK_Sparc_GOT13:    closeParen = false; break;
-  case VK_Sparc_13:       closeParen = false; break;
-  case VK_Sparc_WDISP30:  closeParen = false; break;
-  case VK_Sparc_WPLT30:   closeParen = false; break;
-  case VK_Sparc_R_DISP32: OS << "%r_disp32("; break;
-  case VK_Sparc_TLS_GD_HI22:   OS << "%tgd_hi22(";   break;
-  case VK_Sparc_TLS_GD_LO10:   OS << "%tgd_lo10(";   break;
-  case VK_Sparc_TLS_GD_ADD:    OS << "%tgd_add(";    break;
-  case VK_Sparc_TLS_GD_CALL:   OS << "%tgd_call(";   break;
-  case VK_Sparc_TLS_LDM_HI22:  OS << "%tldm_hi22(";  break;
-  case VK_Sparc_TLS_LDM_LO10:  OS << "%tldm_lo10(";  break;
-  case VK_Sparc_TLS_LDM_ADD:   OS << "%tldm_add(";   break;
-  case VK_Sparc_TLS_LDM_CALL:  OS << "%tldm_call(";  break;
-  case VK_Sparc_TLS_LDO_HIX22: OS << "%tldo_hix22("; break;
-  case VK_Sparc_TLS_LDO_LOX10: OS << "%tldo_lox10("; break;
-  case VK_Sparc_TLS_LDO_ADD:   OS << "%tldo_add(";   break;
-  case VK_Sparc_TLS_IE_HI22:   OS << "%tie_hi22(";   break;
-  case VK_Sparc_TLS_IE_LO10:   OS << "%tie_lo10(";   break;
-  case VK_Sparc_TLS_IE_LD:     OS << "%tie_ld(";     break;
-  case VK_Sparc_TLS_IE_LDX:    OS << "%tie_ldx(";    break;
-  case VK_Sparc_TLS_IE_ADD:    OS << "%tie_add(";    break;
-  case VK_Sparc_TLS_LE_HIX22:  OS << "%tle_hix22(";  break;
-  case VK_Sparc_TLS_LE_LOX10:  OS << "%tle_lox10(";  break;
+  case VK_Sparc_GOT22:    OS << "%hi("; return true;
+  case VK_Sparc_GOT10:    OS << "%lo("; return true;
+  case VK_Sparc_GOT13:    return false;
+  case VK_Sparc_13:       return false;
+  case VK_Sparc_WDISP30:  return false;
+  case VK_Sparc_WPLT30:   return false;
+  case VK_Sparc_R_DISP32: OS << "%r_disp32("; return true;
+  case VK_Sparc_TLS_GD_HI22:   OS << "%tgd_hi22(";   return true;
+  case VK_Sparc_TLS_GD_LO10:   OS << "%tgd_lo10(";   return true;
+  case VK_Sparc_TLS_GD_ADD:    OS << "%tgd_add(";    return true;
+  case VK_Sparc_TLS_GD_CALL:   OS << "%tgd_call(";   return true;
+  case VK_Sparc_TLS_LDM_HI22:  OS << "%tldm_hi22(";  return true;
+  case VK_Sparc_TLS_LDM_LO10:  OS << "%tldm_lo10(";  return true;
+  case VK_Sparc_TLS_LDM_ADD:   OS << "%tldm_add(";   return true;
+  case VK_Sparc_TLS_LDM_CALL:  OS << "%tldm_call(";  return true;
+  case VK_Sparc_TLS_LDO_HIX22: OS << "%tldo_hix22("; return true;
+  case VK_Sparc_TLS_LDO_LOX10: OS << "%tldo_lox10("; return true;
+  case VK_Sparc_TLS_LDO_ADD:   OS << "%tldo_add(";   return true;
+  case VK_Sparc_TLS_IE_HI22:   OS << "%tie_hi22(";   return true;
+  case VK_Sparc_TLS_IE_LO10:   OS << "%tie_lo10(";   return true;
+  case VK_Sparc_TLS_IE_LD:     OS << "%tie_ld(";     return true;
+  case VK_Sparc_TLS_IE_LDX:    OS << "%tie_ldx(";    return true;
+  case VK_Sparc_TLS_IE_ADD:    OS << "%tie_add(";    return true;
+  case VK_Sparc_TLS_LE_HIX22:  OS << "%tle_hix22(";  return true;
+  case VK_Sparc_TLS_LE_LOX10:  OS << "%tle_lox10(";  return true;
   }
-  return closeParen;
+  llvm_unreachable("Unhandled SparcMCExpr::VariantKind");
 }
 
 SparcMCExpr::VariantKind SparcMCExpr::parseVariantKind(StringRef name)


        


More information about the llvm-branch-commits mailing list