[llvm] 16798ee - MC: Use reportFatalUsageError for COFF with non-windows (#147911)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 15 00:27:12 PDT 2025


Author: Matt Arsenault
Date: 2025-07-15T16:27:09+09:00
New Revision: 16798ee7bf86d8c9c68e7b668a52039f2dce35f9

URL: https://github.com/llvm/llvm-project/commit/16798ee7bf86d8c9c68e7b668a52039f2dce35f9
DIFF: https://github.com/llvm/llvm-project/commit/16798ee7bf86d8c9c68e7b668a52039f2dce35f9.diff

LOG: MC: Use reportFatalUsageError for COFF with non-windows (#147911)

Added: 
    

Modified: 
    llvm/lib/MC/MCContext.cpp
    llvm/test/CodeGen/AArch64/unsupported-object-format-err.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index b0d1cb41fac1c..890184db1d1ef 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -87,9 +87,10 @@ MCContext::MCContext(const Triple &TheTriple, const MCAsmInfo *mai,
     Env = IsMachO;
     break;
   case Triple::COFF:
-    if (!TheTriple.isOSWindows() && !TheTriple.isUEFI())
-      report_fatal_error(
-          "Cannot initialize MC for non-Windows COFF object files.");
+    if (!TheTriple.isOSWindows() && !TheTriple.isUEFI()) {
+      reportFatalUsageError(
+          "cannot initialize MC for non-Windows COFF object files");
+    }
 
     Env = IsCOFF;
     break;

diff  --git a/llvm/test/CodeGen/AArch64/unsupported-object-format-err.ll b/llvm/test/CodeGen/AArch64/unsupported-object-format-err.ll
index 740bde5e43c15..0767425d12737 100644
--- a/llvm/test/CodeGen/AArch64/unsupported-object-format-err.ll
+++ b/llvm/test/CodeGen/AArch64/unsupported-object-format-err.ll
@@ -1,10 +1,14 @@
-; RUN: not llc -mtriple=aarch64-pc-unknown-xcoff -filetype=null %s 2>&1 | FileCheck %s
-; RUN: not llc -mtriple=aarch64-pc-unknown-goff -filetype=null %s 2>&1 | FileCheck %s
+; RUN: not llc -mtriple=aarch64-pc-unknown-xcoff -filetype=null %s 2>&1 | FileCheck -check-prefix=OBJFORMAT %s
+; RUN: not llc -mtriple=aarch64-pc-unknown-goff -filetype=null %s 2>&1 | FileCheck -check-prefix=OBJFORMAT %s
+
+; RUN: not llc -mtriple=aarch64-unknown-linux-coff -filetype=null %s 2>&1 | FileCheck -check-prefix=MCINIT %s
+; CHECK: LLVM ERROR: cannot initialize MC for non-Windows COFF object files
 
 ; Make sure there is no crash or assert with unexpected object
 ; formats.
 
-; CHECK: LLVM ERROR: unsupported object format
+; OBJFORMAT: LLVM ERROR: unsupported object format
+; MCINIT: LLVM ERROR: cannot initialize MC for non-Windows COFF object files
 define void @foo() {
   ret void
 }


        


More information about the llvm-commits mailing list