summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-01-22 00:14:49 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-01-22 00:14:49 +0000
commit825fc31bd3a6e7604c4b69f28f32e90b5a882289 (patch)
tree2026366f101c87f4560963d62ecc0138540f31f9 /tools
parent6220c8f960fe287efcfc27f46ab6ad48e5b3c5d2 (diff)
Change createObjectFile to return an ErrorOr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199776 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/lli/lli.cpp6
-rw-r--r--tools/llvm-ar/llvm-ar.cpp6
-rw-r--r--tools/llvm-dwarfdump/llvm-dwarfdump.cpp7
3 files changed, 12 insertions, 7 deletions
diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp
index 8e6669221bf..2ee79793012 100644
--- a/tools/lli/lli.cpp
+++ b/tools/lli/lli.cpp
@@ -527,13 +527,13 @@ int main(int argc, char **argv, char * const *envp) {
}
for (unsigned i = 0, e = ExtraObjects.size(); i != e; ++i) {
- object::ObjectFile *Obj = object::ObjectFile::createObjectFile(
- ExtraObjects[i]);
+ ErrorOr<object::ObjectFile *> Obj =
+ object::ObjectFile::createObjectFile(ExtraObjects[i]);
if (!Obj) {
Err.print(argv[0], errs());
return 1;
}
- EE->addObjectFile(Obj);
+ EE->addObjectFile(Obj.get());
}
for (unsigned i = 0, e = ExtraArchives.size(); i != e; ++i) {
diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp
index 18f87760205..d4fe7d789c8 100644
--- a/tools/llvm-ar/llvm-ar.cpp
+++ b/tools/llvm-ar/llvm-ar.cpp
@@ -670,7 +670,11 @@ static void writeSymbolTable(
object::ObjectFile *Obj;
if (I->isNewMember()) {
const char *Filename = I->getNew();
- Obj = object::ObjectFile::createObjectFile(Filename);
+ if (ErrorOr<object::ObjectFile *> ObjOrErr =
+ object::ObjectFile::createObjectFile(Filename))
+ Obj = ObjOrErr.get();
+ else
+ Obj = NULL;
} else {
object::Archive::child_iterator OldMember = I->getOld();
OwningPtr<object::Binary> Binary;
diff --git a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
index 7c6cc68fb9f..f827909dc31 100644
--- a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -93,11 +93,12 @@ static void DumpInput(const StringRef &Filename) {
return;
}
- OwningPtr<ObjectFile> Obj(ObjectFile::createObjectFile(Buff.take()));
- if (!Obj) {
- errs() << Filename << ": Unknown object file format\n";
+ ErrorOr<ObjectFile*> ObjOrErr(ObjectFile::createObjectFile(Buff.take()));
+ if (error_code EC = ObjOrErr.getError()) {
+ errs() << Filename << ": " << EC.message() << '\n';
return;
}
+ OwningPtr<ObjectFile> Obj(ObjOrErr.get());
OwningPtr<DIContext> DICtx(DIContext::getDWARFContext(Obj.get()));