[PATCH] D111315: Workaround build error for mingw-g++

Luke Drummond via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 7 08:06:57 PDT 2021


ldrumm created this revision.
ldrumm added reviewers: v.g.vassilev, rsmith.
ldrumm added a project: clang.
Herald added a subscriber: mstorsjo.
ldrumm requested review of this revision.

Workaround build error for mingw-g++

      

mingw-g++ does not correctly support the full std::errc namespace as
worded in the standard[1]. As such, we cannot reliably use all names
therein. This patch changes the use of
`std::errc::state_not_recoverable`, to use portable error codes from the
portable llvm::errc equivalent.

      

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71444


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111315

Files:
  clang/lib/Interpreter/Interpreter.cpp


Index: clang/lib/Interpreter/Interpreter.cpp
===================================================================
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -31,6 +31,7 @@
 
 #include "llvm/IR/Module.h"
 #include "llvm/Support/Host.h"
+#include "llvm/Support/Errc.h"
 
 using namespace clang;
 
@@ -47,14 +48,14 @@
   // failed. Extract that job from the Compilation.
   const driver::JobList &Jobs = Compilation->getJobs();
   if (!Jobs.size() || !isa<driver::Command>(*Jobs.begin()))
-    return llvm::createStringError(std::errc::state_not_recoverable,
+    return llvm::createStringError(llvm::errc::io_error,
                                    "Driver initialization failed. "
                                    "Unable to create a driver job");
 
   // The one job we find should be to invoke clang again.
   const driver::Command *Cmd = cast<driver::Command>(&(*Jobs.begin()));
   if (llvm::StringRef(Cmd->getCreator().getName()) != "clang")
-    return llvm::createStringError(std::errc::state_not_recoverable,
+    return llvm::createStringError(llvm::errc::io_error,
                                    "Driver initialization failed");
 
   return &Cmd->getArguments();
@@ -89,13 +90,13 @@
   // Create the actual diagnostics engine.
   Clang->createDiagnostics();
   if (!Clang->hasDiagnostics())
-    return llvm::createStringError(std::errc::state_not_recoverable,
+    return llvm::createStringError(llvm::errc::not_enough_memory,
                                    "Initialization failed. "
                                    "Unable to create diagnostics engine");
 
   DiagsBuffer->FlushDiagnostics(Clang->getDiagnostics());
   if (!Success)
-    return llvm::createStringError(std::errc::state_not_recoverable,
+    return llvm::createStringError(std::errc::io_error,
                                    "Initialization failed. "
                                    "Unable to flush diagnostics");
 
@@ -106,7 +107,7 @@
   Clang->setTarget(TargetInfo::CreateTargetInfo(
       Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
   if (!Clang->hasTarget())
-    return llvm::createStringError(std::errc::state_not_recoverable,
+    return llvm::createStringError(llvm::errc::not_supported,
                                    "Initialization failed. "
                                    "Target is missing");
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111315.377853.patch
Type: text/x-patch
Size: 2387 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211007/a6650761/attachment.bin>


More information about the cfe-commits mailing list