Skip to content

Commit da9dd05

Browse files
committed
Backing out commit r250906 as it broke lld.
llvm-svn: 250908
1 parent 6e91c59 commit da9dd05

File tree

18 files changed

+92
-349
lines changed

18 files changed

+92
-349
lines changed

llvm/include/llvm/Object/Archive.h

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,7 @@ class Archive : public Binary {
6565
bool isThinMember() const;
6666

6767
public:
68-
Child(const Archive *Parent, const char *Start,
69-
std::error_code *EC);
70-
static ErrorOr<std::unique_ptr<Child>> create(const Archive *Parent,
71-
const char *Start);
68+
Child(const Archive *Parent, const char *Start);
7269

7370
bool operator ==(const Child &other) const {
7471
assert(Parent == other.Parent);
@@ -80,7 +77,7 @@ class Archive : public Binary {
8077
}
8178

8279
const Archive *getParent() const { return Parent; }
83-
ErrorOr<Child> getNext() const;
80+
Child getNext() const;
8481

8582
ErrorOr<StringRef> getName() const;
8683
StringRef getRawName() const { return getHeader()->getName(); }
@@ -96,9 +93,9 @@ class Archive : public Binary {
9693
return getHeader()->getAccessMode();
9794
}
9895
/// \return the size of the archive member without the header or padding.
99-
ErrorOr<uint64_t> getSize() const;
96+
uint64_t getSize() const;
10097
/// \return the size in the archive header for this member.
101-
ErrorOr<uint64_t> getRawSize() const;
98+
uint64_t getRawSize() const;
10299

103100
ErrorOr<StringRef> getBuffer() const;
104101
uint64_t getChildOffset() const;
@@ -110,35 +107,28 @@ class Archive : public Binary {
110107
};
111108

112109
class child_iterator {
113-
ErrorOr<Child> child;
110+
Child child;
114111

115112
public:
116-
child_iterator() : child(Child(nullptr, nullptr, nullptr)) {}
113+
child_iterator() : child(Child(nullptr, nullptr)) {}
117114
child_iterator(const Child &c) : child(c) {}
118-
child_iterator(std::error_code EC) : child(EC) {}
119-
const ErrorOr<Child> *operator->() const { return &child; }
120-
const ErrorOr<Child> &operator*() const { return child; }
115+
const Child *operator->() const { return &child; }
116+
const Child &operator*() const { return child; }
121117

122118
bool operator==(const child_iterator &other) const {
123-
if ((*this)->getError())
124-
return false;
125-
if (other->getError())
126-
return false;
127-
return (*this)->get() == other->get();
119+
return child == other.child;
128120
}
129121

130122
bool operator!=(const child_iterator &other) const {
131123
return !(*this == other);
132124
}
133125

134-
// No operator< as we can't do less than compares with iterators that
135-
// contain errors.
126+
bool operator<(const child_iterator &other) const {
127+
return child < other.child;
128+
}
136129

137-
// Code in loops with child_iterators must check for errors on each loop
138-
// iteration. And if there is an error break out of the loop.
139130
child_iterator &operator++() { // Preincrement
140-
assert(child && "Can't increment iterator with error");
141-
child = child->getNext();
131+
child = child.getNext();
142132
return *this;
143133
}
144134
};
@@ -222,7 +212,7 @@ class Archive : public Binary {
222212
StringRef getSymbolTable() const {
223213
// We know that the symbol table is not an external file,
224214
// so we just assert there is no error.
225-
return *(*SymbolTable)->getBuffer();
215+
return *SymbolTable->getBuffer();
226216
}
227217
uint32_t getNumberOfSymbols() const;
228218

llvm/include/llvm/Support/ErrorOr.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ class ErrorOr {
9191
typedef typename std::remove_reference<T>::type &reference;
9292
typedef const typename std::remove_reference<T>::type &const_reference;
9393
typedef typename std::remove_reference<T>::type *pointer;
94-
typedef const typename std::remove_reference<T>::type *const_pointer;
9594

9695
public:
9796
template <class E>
@@ -184,18 +183,10 @@ class ErrorOr {
184183
return toPointer(getStorage());
185184
}
186185

187-
const_pointer operator ->() const {
188-
return toPointer(getStorage());
189-
}
190-
191186
reference operator *() {
192187
return *getStorage();
193188
}
194189

195-
const_reference operator *() const {
196-
return *getStorage();
197-
}
198-
199190
private:
200191
template <class OtherT>
201192
void copyConstruct(const ErrorOr<OtherT> &Other) {
@@ -255,19 +246,10 @@ class ErrorOr {
255246
return Val;
256247
}
257248

258-
const_pointer toPointer(const_pointer Val) const {
259-
return Val;
260-
}
261-
262249
pointer toPointer(wrap *Val) {
263250
return &Val->get();
264251
}
265252

266-
const_pointer toPointer(const wrap *Val) const {
267-
return &Val->get();
268-
}
269-
270-
271253
storage_type *getStorage() {
272254
assert(!HasError && "Cannot get value when an error exists!");
273255
return reinterpret_cast<storage_type*>(TStorage.buffer);

llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,10 @@ RuntimeDyld::SymbolInfo MCJIT::findSymbol(const std::string &Name,
318318
object::Archive *A = OB.getBinary();
319319
// Look for our symbols in each Archive
320320
object::Archive::child_iterator ChildIt = A->findSym(Name);
321-
if (*ChildIt && ChildIt != A->child_end()) {
321+
if (ChildIt != A->child_end()) {
322322
// FIXME: Support nested archives?
323323
ErrorOr<std::unique_ptr<object::Binary>> ChildBinOrErr =
324-
(*ChildIt)->getAsBinary();
324+
ChildIt->getAsBinary();
325325
if (ChildBinOrErr.getError())
326326
continue;
327327
std::unique_ptr<object::Binary> &ChildBin = ChildBinOrErr.get();

llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,10 @@ class OrcMCJITReplacement : public ExecutionEngine {
253253
object::Archive *A = OB.getBinary();
254254
// Look for our symbols in each Archive
255255
object::Archive::child_iterator ChildIt = A->findSym(Name);
256-
if (*ChildIt && ChildIt != A->child_end()) {
256+
if (ChildIt != A->child_end()) {
257257
// FIXME: Support nested archives?
258258
ErrorOr<std::unique_ptr<object::Binary>> ChildBinOrErr =
259-
(*ChildIt)->getAsBinary();
259+
ChildIt->getAsBinary();
260260
if (ChildBinOrErr.getError())
261261
continue;
262262
std::unique_ptr<object::Binary> &ChildBin = ChildBinOrErr.get();

0 commit comments

Comments
 (0)