summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-10-24 22:50:48 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-10-24 22:50:48 +0000
commit5a52e6dc9eeb07e44a62bdc828bc9b8b7348549d (patch)
treed103373d61ab3a674d71ed65a5758610bf5a6482 /llvm/lib
parent2813f496d98f3e6d2c9c2774601999e147af34ef (diff)
downloadbcm5719-llvm-5a52e6dc9eeb07e44a62bdc828bc9b8b7348549d.tar.gz
bcm5719-llvm-5a52e6dc9eeb07e44a62bdc828bc9b8b7348549d.zip
Modernize the error handling of the Materialize function.
llvm-svn: 220600
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp6
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.h2
-rw-r--r--llvm/lib/IR/Globals.cpp4
-rw-r--r--llvm/lib/IR/LegacyPassManager.cpp5
-rw-r--r--llvm/lib/IR/Module.cpp13
-rw-r--r--llvm/lib/Linker/LinkModules.cpp8
6 files changed, 18 insertions, 20 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 507164c8468..45a08b38390 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -56,7 +56,7 @@ std::error_code BitcodeReader::materializeForwardReferencedFunctions() {
return Error(BitcodeError::NeverResolvedFunctionFromBlockAddress);
// Try to materialize F.
- if (std::error_code EC = Materialize(F))
+ if (std::error_code EC = materialize(F))
return EC;
}
assert(BasicBlockFwdRefs.empty() && "Function missing from queue");
@@ -3282,7 +3282,7 @@ std::error_code BitcodeReader::FindFunctionInStream(
void BitcodeReader::releaseBuffer() { Buffer.release(); }
-std::error_code BitcodeReader::Materialize(GlobalValue *GV) {
+std::error_code BitcodeReader::materialize(GlobalValue *GV) {
Function *F = dyn_cast<Function>(GV);
// If it's not a function or is already material, ignore the request.
if (!F || !F->isMaterializable())
@@ -3358,7 +3358,7 @@ std::error_code BitcodeReader::MaterializeModule(Module *M) {
for (Module::iterator F = TheModule->begin(), E = TheModule->end();
F != E; ++F) {
if (F->isMaterializable()) {
- if (std::error_code EC = Materialize(F))
+ if (std::error_code EC = materialize(F))
return EC;
}
}
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.h b/llvm/lib/Bitcode/Reader/BitcodeReader.h
index 9f0f6686121..047fef8fbae 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.h
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.h
@@ -224,7 +224,7 @@ public:
void releaseBuffer();
bool isDematerializable(const GlobalValue *GV) const override;
- std::error_code Materialize(GlobalValue *GV) override;
+ std::error_code materialize(GlobalValue *GV) override;
std::error_code MaterializeModule(Module *M) override;
void Dematerialize(GlobalValue *GV) override;
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 64bc61c5008..cecd999657e 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -36,8 +36,8 @@ bool GlobalValue::isMaterializable() const {
bool GlobalValue::isDematerializable() const {
return getParent() && getParent()->isDematerializable(this);
}
-bool GlobalValue::Materialize(std::string *ErrInfo) {
- return getParent()->Materialize(this, ErrInfo);
+std::error_code GlobalValue::materialize() {
+ return getParent()->materialize(this);
}
void GlobalValue::Dematerialize() {
getParent()->Dematerialize(this);
diff --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp
index 5ba08575134..1081f2a1b8c 100644
--- a/llvm/lib/IR/LegacyPassManager.cpp
+++ b/llvm/lib/IR/LegacyPassManager.cpp
@@ -1404,9 +1404,8 @@ void FunctionPassManager::add(Pass *P) {
///
bool FunctionPassManager::run(Function &F) {
if (F.isMaterializable()) {
- std::string errstr;
- if (F.Materialize(&errstr))
- report_fatal_error("Error reading bitcode file: " + Twine(errstr));
+ if (std::error_code EC = F.materialize())
+ report_fatal_error("Error reading bitcode file: " + EC.message());
}
return FPM->run(F);
}
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index f43080b72ee..e35eefbd45c 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -395,16 +395,11 @@ bool Module::isDematerializable(const GlobalValue *GV) const {
return false;
}
-bool Module::Materialize(GlobalValue *GV, std::string *ErrInfo) {
+std::error_code Module::materialize(GlobalValue *GV) {
if (!Materializer)
- return false;
-
- std::error_code EC = Materializer->Materialize(GV);
- if (!EC)
- return false;
- if (ErrInfo)
- *ErrInfo = EC.message();
- return true;
+ return std::error_code();
+
+ return Materializer->materialize(GV);
}
void Module::Dematerialize(GlobalValue *GV) {
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp
index 510813ad972..c0601430fea 100644
--- a/llvm/lib/Linker/LinkModules.cpp
+++ b/llvm/lib/Linker/LinkModules.cpp
@@ -1626,8 +1626,10 @@ bool ModuleLinker::run() {
// Materialize if needed.
if (SF->isMaterializable()) {
- if (SF->Materialize(&ErrorMsg))
+ if (std::error_code EC = SF->materialize()) {
+ ErrorMsg = EC.message();
return true;
+ }
}
// Skip if no body (function is external).
@@ -1677,8 +1679,10 @@ bool ModuleLinker::run() {
// Materialize if needed.
if (SF->isMaterializable()) {
- if (SF->Materialize(&ErrorMsg))
+ if (std::error_code EC = SF->materialize()) {
+ ErrorMsg = EC.message();
return true;
+ }
}
// Skip if no body (function is external).
OpenPOWER on IntegriCloud