[PATCH] D63767: [NFC] Make some ObjectFormatType switches covering

Hubert Tong via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 25 06:57:49 PDT 2019


hubert.reinterpretcast created this revision.
hubert.reinterpretcast added reviewers: sfertile, jasonliu, daltenty.
Herald added subscribers: jsji, aheejin.
Herald added projects: clang, LLVM.

This patch removes the `default` case from some switches on `llvm::Triple::ObjectFormatType`, and cases for the missing enumerators are then added.

For `UnknownObjectFormat`, the action (`llvm_unreachable`) for the `default` case is kept.

For the other unhandled cases, `report_fatal_error` is used instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63767

Files:
  clang/lib/CodeGen/CGObjCMac.cpp
  llvm/include/llvm/Support/TargetRegistry.h


Index: llvm/include/llvm/Support/TargetRegistry.h
===================================================================
--- llvm/include/llvm/Support/TargetRegistry.h
+++ llvm/include/llvm/Support/TargetRegistry.h
@@ -470,7 +470,7 @@
                                      bool DWARFMustBeAtTheEnd) const {
     MCStreamer *S;
     switch (T.getObjectFormat()) {
-    default:
+    case Triple::UnknownObjectFormat:
       llvm_unreachable("Unknown object format");
     case Triple::COFF:
       assert(T.isOSWindows() && "only Windows COFF is supported");
@@ -504,6 +504,8 @@
         S = createWasmStreamer(Ctx, std::move(TAB), std::move(OW),
                                std::move(Emitter), RelaxAll);
       break;
+    case Triple::XCOFF:
+      report_fatal_error("XCOFF MCObjectStreamer not implemented yet.");
     }
     if (ObjectTargetStreamerCtorFn)
       ObjectTargetStreamerCtorFn(*S, STI);
Index: clang/lib/CodeGen/CGObjCMac.cpp
===================================================================
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -4921,7 +4921,7 @@
 std::string CGObjCCommonMac::GetSectionName(StringRef Section,
                                             StringRef MachOAttributes) {
   switch (CGM.getTriple().getObjectFormat()) {
-  default:
+  case llvm::Triple::UnknownObjectFormat:
     llvm_unreachable("unexpected object file format");
   case llvm::Triple::MachO: {
     if (MachOAttributes.empty())
@@ -4936,6 +4936,10 @@
     assert(Section.substr(0, 2) == "__" &&
            "expected the name to begin with __");
     return ("." + Section.substr(2) + "$B").str();
+  case llvm::Triple::Wasm:
+  case llvm::Triple::XCOFF:
+    llvm::report_fatal_error(
+        "Objective-C support is unimplemented for object file format.");
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63767.206436.patch
Type: text/x-patch
Size: 1812 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190625/3bb760ad/attachment.bin>


More information about the cfe-commits mailing list