Modernize the error handling of the Materialize function.
[oota-llvm.git] / tools / gold / gold-plugin.cpp
index 8ebae0e498c496d0990b6857fce37586e51593bd..2d50f49ffd786456b7e57740dd4ac998c248adcf 100644 (file)
@@ -482,8 +482,11 @@ static GlobalObject *makeInternalReplacement(GlobalObject *GO) {
   Module *M = GO->getParent();
   GlobalObject *Ret;
   if (auto *F = dyn_cast<Function>(GO)) {
-    if (F->isMaterializable())
-      F->Materialize();
+    if (F->isMaterializable()) {
+      if (std::error_code EC = F->materialize())
+        message(LDPL_FATAL, "LLVM gold plugin has failed to read a function");
+
+    }
 
     auto *NewF = Function::Create(F->getFunctionType(), F->getLinkage(),
                                   F->getName(), M);