summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Object/Archive.h2
-rw-r--r--llvm/lib/Object/Archive.cpp11
2 files changed, 8 insertions, 5 deletions
diff --git a/llvm/include/llvm/Object/Archive.h b/llvm/include/llvm/Object/Archive.h
index 14195f869a0..8ab99aa979e 100644
--- a/llvm/include/llvm/Object/Archive.h
+++ b/llvm/include/llvm/Object/Archive.h
@@ -92,7 +92,7 @@ public:
Child(const Archive *Parent, StringRef Data, uint16_t StartOfFile);
bool operator ==(const Child &other) const {
- assert(Parent == other.Parent);
+ assert(!Parent || !other.Parent || Parent == other.Parent);
return Data.begin() == other.Data.begin();
}
diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp
index 73761fa73db..9a83f69705c 100644
--- a/llvm/lib/Object/Archive.cpp
+++ b/llvm/lib/Object/Archive.cpp
@@ -306,8 +306,11 @@ Archive::Child::Child(const Archive *Parent, StringRef Data,
}
Archive::Child::Child(const Archive *Parent, const char *Start, Error *Err)
- : Parent(Parent), Header(Parent, Start, Parent->getData().size() -
- (Start - Parent->getData().data()), Err) {
+ : Parent(Parent),
+ Header(Parent, Start,
+ Parent
+ ? Parent->getData().size() - (Start - Parent->getData().data())
+ : 0, Err) {
if (!Start)
return;
@@ -441,7 +444,7 @@ Expected<Archive::Child> Archive::Child::getNext() const {
// Check to see if this is at the end of the archive.
if (NextLoc == Parent->Data.getBufferEnd())
- return Child(Parent, nullptr, nullptr);
+ return Child(nullptr, nullptr, nullptr);
// Check to see if this is past the end of the archive.
if (NextLoc > Parent->Data.getBufferEnd()) {
@@ -768,7 +771,7 @@ Archive::child_iterator Archive::child_begin(Error &Err,
}
Archive::child_iterator Archive::child_end() const {
- return child_iterator(Child(this, nullptr, nullptr), nullptr);
+ return child_iterator(Child(nullptr, nullptr, nullptr), nullptr);
}
StringRef Archive::Symbol::getName() const {
OpenPOWER on IntegriCloud