Steal LLVM.h from Clang. This brings in very commonly used LLVM ADT/Support
types into the lld namespace.
llvm-svn: 153963
diff --git a/lld/lib/Core/File.cpp b/lld/lib/Core/File.cpp
index 995993e..ffca9cb 100644
--- a/lld/lib/Core/File.cpp
+++ b/lld/lib/Core/File.cpp
@@ -8,13 +8,14 @@
//===----------------------------------------------------------------------===//
#include "lld/Core/File.h"
+#include "lld/Core/LLVM.h"
namespace lld {
File::~File() {}
-llvm::StringRef File::translationUnitSource() const {
- return llvm::StringRef();
+StringRef File::translationUnitSource() const {
+ return StringRef();
}
diff --git a/lld/lib/Core/NativeReader.cpp b/lld/lib/Core/NativeReader.cpp
index 1bb0d55..2f92626 100644
--- a/lld/lib/Core/NativeReader.cpp
+++ b/lld/lib/Core/NativeReader.cpp
@@ -40,8 +40,8 @@
virtual uint64_t ordinal() const;
- virtual llvm::StringRef name() const;
+ virtual StringRef name() const;
virtual uint64_t size() const {
return _ivarData->contentSize;
}
@@ -71,7 +71,7 @@
return (DefinedAtom::SectionChoice)(attributes().sectionChoice);
}
- virtual llvm::StringRef customSectionName() const;
+ virtual StringRef customSectionName() const;
virtual DefinedAtom::DeadStripKind deadStrip() const {
return (DefinedAtom::DeadStripKind)(attributes().deadStrip);
@@ -89,8 +89,8 @@
return (attributes().alias != 0);
}
- virtual llvm::ArrayRef<uint8_t> rawContent() const;
+ virtual ArrayRef<uint8_t> rawContent() const;
virtual reference_iterator referencesBegin() const;
virtual reference_iterator referencesEnd() const;
@@ -119,7 +119,7 @@
: _file(&f), _ivarData(ivarData) { }
virtual const File& file() const;
- virtual llvm::StringRef name() const;
+ virtual StringRef name() const;
virtual CanBeNull canBeNull() const {
return (CanBeNull)(_ivarData->flags & 0x3);
@@ -143,8 +143,8 @@
: _file(&f), _ivarData(ivarData) { }
virtual const File& file() const;
- virtual llvm::StringRef name() const;
- virtual llvm::StringRef loadName() const;
+ virtual StringRef name() const;
+ virtual StringRef loadName() const;
virtual bool canBeNullAtRuntime() const {
return (_ivarData->flags & 0x1);
@@ -167,7 +167,7 @@
: _file(&f), _ivarData(ivarData) { }
virtual const File& file() const;
- virtual llvm::StringRef name() const;
+ virtual StringRef name() const;
virtual uint64_t value() const {
return _ivarData->value;
@@ -228,9 +228,9 @@
/// Instantiates a File object from a native object file. Ownership
/// of the MemoryBuffer is transfered to the resulting File object.
- static llvm::error_code make(std::unique_ptr<llvm::MemoryBuffer> mb,
- llvm::StringRef path,
- std::unique_ptr<File> &result) {
+ static error_code make(std::unique_ptr<llvm::MemoryBuffer> mb,
+ StringRef path,
+ std::unique_ptr<File> &result) {
const uint8_t* const base =
reinterpret_cast<const uint8_t*>(mb->getBufferStart());
const NativeFileHeader* const header =
@@ -251,7 +251,7 @@
// process each chunk
for(uint32_t i=0; i < header->chunkCount; ++i) {
- llvm::error_code ec;
+ error_code ec;
const NativeChunk* chunk = &chunks[i];
// sanity check chunk is within file
if ( chunk->fileOffset > fileSize )
@@ -343,8 +343,8 @@
friend class NativeReferenceV1;
// instantiate array of DefinedAtoms from v1 ivar data in file
- llvm::error_code processDefinedAtomsV1(const uint8_t* base,
- const NativeChunk* chunk) {
+ error_code processDefinedAtomsV1(const uint8_t *base,
+ const NativeChunk *chunk) {
const size_t atomSize = sizeof(NativeDefinedAtomV1);
size_t atomsArraySize = chunk->elementCount * atomSize;
uint8_t* atomsStart = reinterpret_cast<uint8_t*>
@@ -373,16 +373,16 @@
}
// set up pointers to attributes array
- llvm::error_code processAttributesV1(const uint8_t* base,
- const NativeChunk* chunk) {
+ error_code processAttributesV1(const uint8_t *base,
+ const NativeChunk *chunk) {
this->_attributes = base + chunk->fileOffset;
this->_attributesMaxOffset = chunk->fileSize;
return make_error_code(native_reader_error::success);
}
// instantiate array of UndefinedAtoms from v1 ivar data in file
- llvm::error_code processUndefinedAtomsV1(const uint8_t* base,
- const NativeChunk* chunk) {
+ error_code processUndefinedAtomsV1(const uint8_t *base,
+ const NativeChunk *chunk) {
const size_t atomSize = sizeof(NativeUndefinedAtomV1);
size_t atomsArraySize = chunk->elementCount * atomSize;
uint8_t* atomsStart = reinterpret_cast<uint8_t*>
@@ -412,8 +412,8 @@
// instantiate array of ShareLibraryAtoms from v1 ivar data in file
- llvm::error_code processSharedLibraryAtomsV1(const uint8_t* base,
- const NativeChunk* chunk) {
+ error_code processSharedLibraryAtomsV1(const uint8_t *base,
+ const NativeChunk *chunk) {
const size_t atomSize = sizeof(NativeSharedLibraryAtomV1);
size_t atomsArraySize = chunk->elementCount * atomSize;
uint8_t* atomsStart = reinterpret_cast<uint8_t*>
@@ -443,8 +443,8 @@
// instantiate array of AbsoluteAtoms from v1 ivar data in file
- llvm::error_code processAbsoluteAtomsV1(const uint8_t* base,
- const NativeChunk* chunk) {
+ error_code processAbsoluteAtomsV1(const uint8_t *base,
+ const NativeChunk *chunk) {
const size_t atomSize = sizeof(NativeAbsoluteAtomV1);
size_t atomsArraySize = chunk->elementCount * atomSize;
uint8_t* atomsStart = reinterpret_cast<uint8_t*>
@@ -476,8 +476,8 @@
// instantiate array of Referemces from v1 ivar data in file
- llvm::error_code processReferencesV1(const uint8_t* base,
- const NativeChunk* chunk) {
+ error_code processReferencesV1(const uint8_t *base,
+ const NativeChunk *chunk) {
if ( chunk->elementCount == 0 )
return make_error_code(native_reader_error::success);
const size_t refSize = sizeof(NativeReferenceV1);
@@ -508,8 +508,8 @@
}
// set up pointers to target table
- llvm::error_code processTargetsTable(const uint8_t* base,
- const NativeChunk* chunk) {
+ error_code processTargetsTable(const uint8_t *base,
+ const NativeChunk *chunk) {
const uint32_t* targetIndexes = reinterpret_cast<const uint32_t*>
(base + chunk->fileOffset);
this->_targetsTableCount = chunk->elementCount;
@@ -553,8 +553,8 @@
// set up pointers to addend pool in file
- llvm::error_code processAddendsTable(const uint8_t* base,
- const NativeChunk* chunk) {
+ error_code processAddendsTable(const uint8_t *base,
+ const NativeChunk *chunk) {
this->_addends = reinterpret_cast<const Reference::Addend*>
(base + chunk->fileOffset);
this->_addendsMaxIndex = chunk->elementCount;
@@ -562,24 +562,24 @@
}
// set up pointers to string pool in file
- llvm::error_code processStrings(const uint8_t* base,
- const NativeChunk* chunk) {
+ error_code processStrings(const uint8_t *base,
+ const NativeChunk *chunk) {
this->_strings = reinterpret_cast<const char*>(base + chunk->fileOffset);
this->_stringsMaxOffset = chunk->fileSize;
return make_error_code(native_reader_error::success);
}
// set up pointers to content area in file
- llvm::error_code processContent(const uint8_t* base,
- const NativeChunk* chunk) {
+ error_code processContent(const uint8_t *base,
+ const NativeChunk *chunk) {
this->_contentStart = base + chunk->fileOffset;
this->_contentEnd = base + chunk->fileOffset + chunk->fileSize;
return make_error_code(native_reader_error::success);
}
- llvm::StringRef string(uint32_t offset) const {
+ StringRef string(uint32_t offset) const {
assert(offset < _stringsMaxOffset);
- return llvm::StringRef(&_strings[offset]);
+ return StringRef(&_strings[offset]);
}
Reference::Addend addend(uint32_t index) const {
@@ -618,8 +618,8 @@
// private constructor, only called by make()
- NativeFile(std::unique_ptr<llvm::MemoryBuffer> mb, llvm::StringRef path) :
- lld::File(path),
+ NativeFile(std::unique_ptr<llvm::MemoryBuffer> mb, StringRef path) :
+ File(path),
_buffer(std::move(mb)), // NativeFile now takes ownership of buffer
_header(nullptr),
_targetsTable(nullptr),
@@ -704,7 +704,7 @@
return p - _file->_definedAtoms._arrayStart;
}
-inline llvm::StringRef NativeDefinedAtomV1::name() const {
+inline StringRef NativeDefinedAtomV1::name() const {
return _file->string(_ivarData->nameOffset);
}
@@ -712,15 +712,15 @@
return _file->attribute(_ivarData->attributesOffset);
}
-inline llvm::ArrayRef<uint8_t> NativeDefinedAtomV1::rawContent() const {
+inline ArrayRef<uint8_t> NativeDefinedAtomV1::rawContent() const {
if ( this->contentType() == DefinedAtom::typeZeroFill )
- return llvm::ArrayRef<uint8_t>();
+ return ArrayRef<uint8_t>();
const uint8_t* p = _file->content(_ivarData->contentOffset,
_ivarData->contentSize);
- return llvm::ArrayRef<uint8_t>(p, _ivarData->contentSize);
+ return ArrayRef<uint8_t>(p, _ivarData->contentSize);
}
-inline llvm::StringRef NativeDefinedAtomV1::customSectionName() const {
+inline StringRef NativeDefinedAtomV1::customSectionName() const {
uint32_t offset = attributes().sectionNameOffset;
return _file->string(offset);
}
@@ -752,7 +752,7 @@
return *_file;
}
-inline llvm::StringRef NativeUndefinedAtomV1::name() const {
+inline StringRef NativeUndefinedAtomV1::name() const {
return _file->string(_ivarData->nameOffset);
}
@@ -763,11 +763,11 @@
return *_file;
}
-inline llvm::StringRef NativeSharedLibraryAtomV1::name() const {
+inline StringRef NativeSharedLibraryAtomV1::name() const {
return _file->string(_ivarData->nameOffset);
}
-inline llvm::StringRef NativeSharedLibraryAtomV1::loadName() const {
+inline StringRef NativeSharedLibraryAtomV1::loadName() const {
return _file->string(_ivarData->loadNameOffset);
}
@@ -777,7 +777,7 @@
return *_file;
}
-inline llvm::StringRef NativeAbsoluteAtomV1::name() const {
+inline StringRef NativeAbsoluteAtomV1::name() const {
return _file->string(_ivarData->nameOffset);
}
@@ -803,9 +803,9 @@
//
// Instantiate an lld::File from the given native object file buffer
//
-llvm::error_code parseNativeObjectFile(std::unique_ptr<llvm::MemoryBuffer> mb,
- llvm::StringRef path,
- std::unique_ptr<File> &result) {
+error_code parseNativeObjectFile(std::unique_ptr<llvm::MemoryBuffer> mb,
+ StringRef path,
+ std::unique_ptr<File> &result) {
return NativeFile::make(std::move(mb), path, result);
}
@@ -814,11 +814,11 @@
//
// Instantiate an lld::File from the given native object file path
//
-llvm::error_code parseNativeObjectFileOrSTDIN(llvm::StringRef path,
- std::unique_ptr<File>& result) {
- llvm::OwningPtr<llvm::MemoryBuffer> mb;
- llvm::error_code ec = llvm::MemoryBuffer::getFileOrSTDIN(path, mb);
- if ( ec )
+error_code parseNativeObjectFileOrSTDIN(StringRef path,
+ std::unique_ptr<File>& result) {
+ OwningPtr<llvm::MemoryBuffer> mb;
+ error_code ec = llvm::MemoryBuffer::getFileOrSTDIN(path, mb);
+ if ( ec )
return ec;
return parseNativeObjectFile( std::unique_ptr<llvm::MemoryBuffer>(mb.take())
diff --git a/lld/lib/Core/NativeWriter.cpp b/lld/lib/Core/NativeWriter.cpp
index 5af2326..4a0916b 100644
--- a/lld/lib/Core/NativeWriter.cpp
+++ b/lld/lib/Core/NativeWriter.cpp
@@ -58,7 +58,7 @@
}
// write the lld::File in native format to the specified stream
- void write(llvm::raw_ostream& out) {
+ void write(raw_ostream &out) {
assert( out.tell() == 0 );
out.write((char*)_headerBuffer, _headerBufferSize);
@@ -323,7 +323,7 @@
}
// check if name is already in pool or append and return offset
- uint32_t getSharedLibraryNameOffset(llvm::StringRef name) {
+ uint32_t getSharedLibraryNameOffset(StringRef name) {
assert( ! name.empty() );
// look to see if this library name was used by another atom
for(NameToOffsetVector::iterator it = _sharedLibraryNames.begin();
@@ -338,7 +338,7 @@
}
// append atom name to string pool and return offset
- uint32_t getNameOffset(llvm::StringRef name) {
+ uint32_t getNameOffset(StringRef name) {
if ( name.empty() )
return 0;
uint32_t result = _stringPool.size();
@@ -352,7 +352,7 @@
if ( atom.contentType() == DefinedAtom::typeZeroFill )
return 0;
uint32_t result = _contentPool.size();
- llvm::ArrayRef<uint8_t> cont = atom.rawContent();
+ ArrayRef<uint8_t> cont = atom.rawContent();
_contentPool.insert(_contentPool.end(), cont.begin(), cont.end());
return result;
}
@@ -377,7 +377,7 @@
// if section based on content, then no custom section name available
if ( atom.sectionChoice() == DefinedAtom::sectionBasedOnContent )
return 0;
- llvm::StringRef name = atom.customSectionName();
+ StringRef name = atom.customSectionName();
assert( ! name.empty() );
// look to see if this section name was used by another atom
for(NameToOffsetVector::iterator it=_sectionNames.begin();
@@ -495,8 +495,8 @@
return result;
}
- void writeAddendTable(llvm::raw_ostream& out) {
// Build table of addends
+ void writeAddendTable(raw_ostream &out) {
uint32_t maxAddendIndex = _addendsTableIndex.size();
std::vector<Reference::Addend> addends(maxAddendIndex);
for (AddendToIndex::iterator it = _addendsTableIndex.begin();
@@ -510,7 +510,7 @@
out.write((char*)&addends[0], maxAddendIndex*sizeof(Reference::Addend));
}
- typedef std::vector<std::pair<llvm::StringRef, uint32_t> > NameToOffsetVector;
+ typedef std::vector<std::pair<StringRef, uint32_t> > NameToOffsetVector;
typedef llvm::DenseMap<const Atom*, uint32_t> TargetToIndex;
typedef llvm::DenseMap<Reference::Addend, uint32_t> AddendToIndex;
@@ -542,18 +542,20 @@
/// writeNativeObjectFile - writes the lld::File object in native object
/// file format to the specified stream.
-int writeNativeObjectFile(const lld::File &file, llvm::raw_ostream &out) {
- NativeWriter writer(file);
+int writeNativeObjectFile(const File &file, raw_ostream &out) {
+ NativeWriter writer(file);
writer.write(out);
return 0;
}
/// writeNativeObjectFile - writes the lld::File object in native object
/// file format to the specified file path.
-int writeNativeObjectFile(const lld::File& file, llvm::StringRef path) {
+int writeNativeObjectFile(const File &file, StringRef path) {
std::string errorInfo;
- llvm::raw_fd_ostream out(path.data(), errorInfo, llvm::raw_fd_ostream::F_Binary);
- if ( !errorInfo.empty() )
+ llvm::raw_fd_ostream out( path.data()
+ , errorInfo
+ , llvm::raw_fd_ostream::F_Binary);
+ if (!errorInfo.empty())
return -1;
return writeNativeObjectFile(file, out);
}
diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp
index cbef66f..f11e08a 100644
--- a/lld/lib/Core/Resolver.cpp
+++ b/lld/lib/Core/Resolver.cpp
@@ -11,11 +11,11 @@
#include "lld/Core/Atom.h"
#include "lld/Core/File.h"
#include "lld/Core/InputFiles.h"
+#include "lld/Core/LLVM.h"
#include "lld/Core/Platform.h"
#include "lld/Core/SymbolTable.h"
#include "lld/Core/UndefinedAtom.h"
-#include "llvm/Support/Casting.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
@@ -34,7 +34,7 @@
if ( _liveAtoms.count(atom) )
return false;
// don't remove if marked never-dead-strip
- if (const DefinedAtom* defAtom = llvm::dyn_cast<DefinedAtom>(atom)) {
+ if (const DefinedAtom* defAtom = dyn_cast<DefinedAtom>(atom)) {
if ( defAtom->deadStrip() == DefinedAtom::deadStripNever )
return false;
}
@@ -176,7 +176,7 @@
_symbolTable.undefines(undefines);
for (std::vector<const Atom *>::iterator it = undefines.begin();
it != undefines.end(); ++it) {
- llvm::StringRef undefName = (*it)->name();
+ StringRef undefName = (*it)->name();
// load for previous undefine may also have loaded this undefine
if (!_symbolTable.isDefined(undefName)) {
_inputFiles.searchLibraries(undefName, true, true, false, *this);
@@ -195,7 +195,7 @@
std::vector<const Atom *> tents;
for (std::vector<const Atom *>::iterator ait = _atoms.begin();
ait != _atoms.end(); ++ait) {
- if (const DefinedAtom* defAtom = llvm::dyn_cast<DefinedAtom>(*ait)) {
+ if (const DefinedAtom* defAtom = dyn_cast<DefinedAtom>(*ait)) {
if ( defAtom->merge() == DefinedAtom::mergeAsTentative )
tents.push_back(defAtom);
}
@@ -204,11 +204,10 @@
dit != tents.end(); ++dit) {
// load for previous tentative may also have loaded
// this tentative, so check again
- llvm::StringRef tentName = (*dit)->name();
+ StringRef tentName = (*dit)->name();
const Atom *curAtom = _symbolTable.findByName(tentName);
assert(curAtom != nullptr);
- if (const DefinedAtom* curDefAtom =
- llvm::dyn_cast<DefinedAtom>(curAtom)) {
+ if (const DefinedAtom* curDefAtom = dyn_cast<DefinedAtom>(curAtom)) {
if (curDefAtom->merge() == DefinedAtom::mergeAsTentative )
_inputFiles.searchLibraries(tentName, searchDylibs,
true, true, *this);
@@ -223,7 +222,7 @@
// to the new defined atom
void Resolver::updateReferences() {
for (auto ait = _atoms.begin(); ait != _atoms.end(); ++ait) {
- if (const DefinedAtom* defAtom = llvm::dyn_cast<DefinedAtom>(*ait)) {
+ if (const DefinedAtom* defAtom = dyn_cast<DefinedAtom>(*ait)) {
for (auto rit=defAtom->referencesBegin(), end=defAtom->referencesEnd();
rit != end; ++rit) {
const Reference* ref = *rit;
@@ -261,7 +260,7 @@
WhyLiveBackChain thisChain;
thisChain.previous = previous;
thisChain.referer = &atom;
- if ( const DefinedAtom* defAtom = llvm::dyn_cast<DefinedAtom>(&atom)) {
+ if ( const DefinedAtom* defAtom = dyn_cast<DefinedAtom>(&atom)) {
for (auto rit=defAtom->referencesBegin(), end=defAtom->referencesEnd();
rit != end; ++rit) {
const Reference* ref = *rit;
@@ -287,7 +286,7 @@
// add -exported_symbols_list, -init, and -u entries to live roots
for (Platform::UndefinesIterator uit = _platform.initialUndefinesBegin();
uit != _platform.initialUndefinesEnd(); ++uit) {
- llvm::StringRef sym = *uit;
+ StringRef sym = *uit;
const Atom *symAtom = _symbolTable.findByName(sym);
assert(symAtom->definition() != Atom::definitionUndefined);
_deadStripRoots.insert(symAtom);
@@ -344,7 +343,7 @@
void Resolver::checkDylibSymbolCollisions() {
for (std::vector<const Atom *>::const_iterator it = _atoms.begin();
it != _atoms.end(); ++it) {
- const DefinedAtom* defAtom = llvm::dyn_cast<DefinedAtom>(*it);
+ const DefinedAtom* defAtom = dyn_cast<DefinedAtom>(*it);
if (defAtom == nullptr)
continue;
if ( defAtom->merge() != DefinedAtom::mergeAsTentative )
@@ -359,7 +358,7 @@
// get "main" atom for linkage unit
const Atom *Resolver::entryPoint() {
- llvm::StringRef symbolName = _platform.entryPointName();
+ StringRef symbolName = _platform.entryPointName();
if (symbolName != nullptr)
return _symbolTable.findByName(symbolName);
@@ -391,15 +390,14 @@
}
void Resolver::MergedFile::addAtom(const Atom& atom) {
- if (const DefinedAtom* defAtom = llvm::dyn_cast<DefinedAtom>(&atom)) {
+ if (const DefinedAtom* defAtom = dyn_cast<DefinedAtom>(&atom)) {
_definedAtoms._atoms.push_back(defAtom);
- } else if (const UndefinedAtom* undefAtom =
- llvm::dyn_cast<UndefinedAtom>(&atom)) {
+ } else if (const UndefinedAtom* undefAtom = dyn_cast<UndefinedAtom>(&atom)) {
_undefinedAtoms._atoms.push_back(undefAtom);
} else if (const SharedLibraryAtom* slAtom =
- llvm::dyn_cast<SharedLibraryAtom>(&atom)) {
+ dyn_cast<SharedLibraryAtom>(&atom)) {
_sharedLibraryAtoms._atoms.push_back(slAtom);
- } else if (const AbsoluteAtom* abAtom = llvm::dyn_cast<AbsoluteAtom>(&atom)) {
+ } else if (const AbsoluteAtom* abAtom = dyn_cast<AbsoluteAtom>(&atom)) {
_absoluteAtoms._atoms.push_back(abAtom);
} else {
assert(0 && "atom has unknown definition kind");
diff --git a/lld/lib/Core/SymbolTable.cpp b/lld/lib/Core/SymbolTable.cpp
index b748e00..66a54f7 100644
--- a/lld/lib/Core/SymbolTable.cpp
+++ b/lld/lib/Core/SymbolTable.cpp
@@ -13,6 +13,7 @@
#include "lld/Core/DefinedAtom.h"
#include "lld/Core/File.h"
#include "lld/Core/InputFiles.h"
+#include "lld/Core/LLVM.h"
#include "lld/Core/Platform.h"
#include "lld/Core/Resolver.h"
#include "lld/Core/SharedLibraryAtom.h"
@@ -20,7 +21,6 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMapInfo.h"
-#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
@@ -125,7 +125,7 @@
void SymbolTable::addByName(const Atom & newAtom) {
- llvm::StringRef name = newAtom.name();
+ StringRef name = newAtom.name();
const Atom *existing = this->findByName(name);
if (existing == nullptr) {
// Name is not in symbol table yet, add it associate with this atom.
@@ -162,9 +162,9 @@
break;
case NCR_DupUndef: {
const UndefinedAtom* existingUndef =
- llvm::dyn_cast<UndefinedAtom>(existing);
+ dyn_cast<UndefinedAtom>(existing);
const UndefinedAtom* newUndef =
- llvm::dyn_cast<UndefinedAtom>(&newAtom);
+ dyn_cast<UndefinedAtom>(&newAtom);
assert(existingUndef != nullptr);
assert(newUndef != nullptr);
if ( existingUndef->canBeNull() == newUndef->canBeNull() ) {
@@ -180,9 +180,9 @@
break;
case NCR_DupShLib: {
const SharedLibraryAtom* existingShLib =
- llvm::dyn_cast<SharedLibraryAtom>(existing);
+ dyn_cast<SharedLibraryAtom>(existing);
const SharedLibraryAtom* newShLib =
- llvm::dyn_cast<SharedLibraryAtom>(&newAtom);
+ dyn_cast<SharedLibraryAtom>(&newAtom);
assert(existingShLib != nullptr);
assert(newShLib != nullptr);
if ( (existingShLib->canBeNullAtRuntime()
@@ -217,7 +217,7 @@
unsigned SymbolTable::AtomMappingInfo::getHashValue(const DefinedAtom * const atom) {
unsigned hash = atom->size();
if ( atom->contentType() != DefinedAtom::typeZeroFill ) {
- llvm::ArrayRef<uint8_t> content = atom->rawContent();
+ ArrayRef<uint8_t> content = atom->rawContent();
for (unsigned int i=0; i < content.size(); ++i) {
hash = hash * 33 + content[i];
}
@@ -241,13 +241,13 @@
return false;
if ( r == getTombstoneKey() )
return false;
-
+
if ( l->contentType() != r->contentType() )
return false;
if ( l->size() != r->size() )
return false;
- llvm::ArrayRef<uint8_t> lc = l->rawContent();
- llvm::ArrayRef<uint8_t> rc = r->rawContent();
+ ArrayRef<uint8_t> lc = l->rawContent();
+ ArrayRef<uint8_t> rc = r->rawContent();
return lc.equals(rc);
}
@@ -265,14 +265,14 @@
-const Atom *SymbolTable::findByName(llvm::StringRef sym) {
+const Atom *SymbolTable::findByName(StringRef sym) {
NameToAtom::iterator pos = _nameTable.find(sym);
if (pos == _nameTable.end())
return nullptr;
return pos->second;
}
-bool SymbolTable::isDefined(llvm::StringRef sym) {
+bool SymbolTable::isDefined(StringRef sym) {
const Atom *atom = this->findByName(sym);
if (atom == nullptr)
return false;
diff --git a/lld/lib/Core/YamlReader.cpp b/lld/lib/Core/YamlReader.cpp
index 3bfa0cf..93072ac 100644
--- a/lld/lib/Core/YamlReader.cpp
+++ b/lld/lib/Core/YamlReader.cpp
@@ -13,6 +13,7 @@
#include "lld/Core/AbsoluteAtom.h"
#include "lld/Core/Error.h"
#include "lld/Core/File.h"
+#include "lld/Core/LLVM.h"
#include "lld/Core/Platform.h"
#include "lld/Core/Reference.h"
#include "lld/Core/SharedLibraryAtom.h"
@@ -385,9 +386,9 @@
return _file;
}
- virtual llvm::StringRef name() const {
+ virtual StringRef name() const {
if (_name == nullptr)
- return llvm::StringRef();
+ return StringRef();
else
return _name;
}
@@ -420,7 +421,7 @@
return _sectionChoice;
}
- virtual llvm::StringRef customSectionName() const {
+ virtual StringRef customSectionName() const {
return _sectionName;
}
@@ -440,11 +441,11 @@
return _isAlias;
}
- llvm::ArrayRef<uint8_t> rawContent() const {
+ ArrayRef<uint8_t> rawContent() const {
if (_content != nullptr)
- return llvm::ArrayRef<uint8_t>(*_content);
+ return ArrayRef<uint8_t>(*_content);
else
- return llvm::ArrayRef<uint8_t>();
+ return ArrayRef<uint8_t>();
}
virtual uint64_t ordinal() const {
@@ -519,7 +520,7 @@
return _file;
}
- virtual llvm::StringRef name() const {
+ virtual StringRef name() const {
return _name;
}
@@ -548,11 +549,11 @@
return _file;
}
- virtual llvm::StringRef name() const {
+ virtual StringRef name() const {
return _name;
}
- virtual llvm::StringRef loadName() const {
+ virtual StringRef loadName() const {
return _loadName;
}
@@ -580,7 +581,7 @@
return _file;
}
- virtual llvm::StringRef name() const {
+ virtual StringRef name() const {
return _name;
}
@@ -765,12 +766,12 @@
}
void YAMLAtomState::setAlign2(const char *s) {
- if (llvm::StringRef(s).getAsInteger(10, _alignment.powerOf2))
+ if (StringRef(s).getAsInteger(10, _alignment.powerOf2))
_alignment.powerOf2 = 1;
}
void YAMLAtomState::setFixupKind(const char *s) {
- _ref._kind = _platform.kindFromString(llvm::StringRef(s));
+ _ref._kind = _platform.kindFromString(StringRef(s));
}
void YAMLAtomState::setFixupTarget(const char *s) {
@@ -797,9 +798,9 @@
/// parseObjectText - Parse the specified YAML formatted MemoryBuffer
/// into lld::File object(s) and append each to the specified vector<File*>.
-llvm::error_code parseObjectText( llvm::MemoryBuffer *mb
- , Platform& platform
- , std::vector<const File *> &result) {
+error_code parseObjectText( llvm::MemoryBuffer *mb
+ , Platform& platform
+ , std::vector<const File *> &result) {
std::vector<const YAML::Entry *> entries;
YAML::parse(mb, entries);
@@ -912,7 +913,7 @@
haveAtom = true;
}
else if (strcmp(entry->key, KeyValues::sizeKeyword) == 0) {
- llvm::StringRef val = entry->value;
+ StringRef val = entry->value;
if (val.getAsInteger(0, atomState._size))
return make_error_code(yaml_reader_error::illegal_value);
haveAtom = true;
@@ -934,7 +935,7 @@
}
else if (strcmp(entry->key, KeyValues::valueKeyword) == 0) {
llvm::APInt Val;
- llvm::StringRef(entry->value).getAsInteger(0, Val);
+ StringRef(entry->value).getAsInteger(0, Val);
atomState._value = Val.getZExtValue();
haveAtom = true;
}
@@ -954,7 +955,7 @@
haveFixup = true;
}
else if (strcmp(entry->key, KeyValues::fixupsOffsetKeyword) == 0) {
- if (llvm::StringRef(entry->value).getAsInteger(0,
+ if (StringRef(entry->value).getAsInteger(0,
atomState._ref._offsetInAtom))
return make_error_code(yaml_reader_error::illegal_value);
haveFixup = true;
@@ -964,7 +965,7 @@
haveFixup = true;
}
else if (strcmp(entry->key, KeyValues::fixupsAddendKeyword) == 0) {
- llvm::StringRef Addend(entry->value);
+ StringRef Addend(entry->value);
if (Addend.getAsInteger(0, atomState._ref._addend))
return make_error_code(yaml_reader_error::illegal_value);
haveFixup = true;
@@ -987,17 +988,15 @@
//
// Fill in vector<File*> from path to input text file.
//
-llvm::error_code parseObjectTextFileOrSTDIN(llvm::StringRef path
- , Platform& platform
- , std::vector<const File*>& result) {
- llvm::OwningPtr<llvm::MemoryBuffer> mb;
- llvm::error_code ec = llvm::MemoryBuffer::getFileOrSTDIN(path, mb);
- if ( ec )
- return ec;
-
+error_code parseObjectTextFileOrSTDIN( StringRef path
+ , Platform& platform
+ , std::vector<const File*>& result) {
+ OwningPtr<llvm::MemoryBuffer> mb;
+ if (error_code ec = llvm::MemoryBuffer::getFileOrSTDIN(path, mb))
+ return ec;
+
return parseObjectText(mb.get(), platform, result);
}
-
} // namespace yaml
} // namespace lld
diff --git a/lld/lib/Core/YamlWriter.cpp b/lld/lib/Core/YamlWriter.cpp
index 15ebe62..e069baa 100644
--- a/lld/lib/Core/YamlWriter.cpp
+++ b/lld/lib/Core/YamlWriter.cpp
@@ -115,7 +115,7 @@
return _refNames.count(atom);
}
- llvm::StringRef refName(const Atom* atom) {
+ StringRef refName(const Atom *atom) {
return _refNames.find(atom)->second;
}
@@ -139,7 +139,7 @@
: _file(file), _platform(platform), _rnb(rnb), _firstAtom(true) { }
- void write(llvm::raw_ostream& out) {
+ void write(raw_ostream &out) {
// write header
out << "---\n";
@@ -169,7 +169,7 @@
}
- void writeDefinedAtom(const DefinedAtom &atom, llvm::raw_ostream& out) {
+ void writeDefinedAtom(const DefinedAtom &atom, raw_ostream &out) {
if ( _firstAtom ) {
out << "atoms:\n";
_firstAtom = false;
@@ -297,7 +297,7 @@
<< ":"
<< spacePadding(KeyValues::contentKeyword)
<< "[ ";
- llvm::ArrayRef<uint8_t> arr = atom.rawContent();
+ ArrayRef<uint8_t> arr = atom.rawContent();
bool needComma = false;
for (unsigned int i=0; i < arr.size(); ++i) {
if ( needComma )
@@ -334,7 +334,7 @@
<< "\n";
const Atom* target = ref->target();
if (target != nullptr) {
- llvm::StringRef refName = target->name();
+ StringRef refName = target->name();
if ( _rnb.hasRefName(target) )
refName = _rnb.refName(target);
assert(!refName.empty());
@@ -357,7 +357,7 @@
}
- void writeUndefinedAtom(const UndefinedAtom &atom, llvm::raw_ostream& out) {
+ void writeUndefinedAtom(const UndefinedAtom &atom, raw_ostream &out) {
if ( _firstAtom ) {
out << "atoms:\n";
_firstAtom = false;
@@ -391,7 +391,7 @@
}
}
- void writeSharedLibraryAtom(const SharedLibraryAtom& atom, llvm::raw_ostream& out) {
+ void writeSharedLibraryAtom(const SharedLibraryAtom &atom, raw_ostream &out) {
if ( _firstAtom ) {
out << "atoms:\n";
_firstAtom = false;
@@ -434,7 +434,7 @@
}
}
- void writeAbsoluteAtom(const AbsoluteAtom& atom, llvm::raw_ostream& out) {
+ void writeAbsoluteAtom(const AbsoluteAtom &atom, raw_ostream &out) {
if ( _firstAtom ) {
out << "atoms:\n";
_firstAtom = false;
@@ -497,8 +497,7 @@
/// writeObjectText - writes the lld::File object as in YAML
/// format to the specified stream.
///
-void writeObjectText(const File& file, Platform& platform,
- llvm::raw_ostream &out) {
+void writeObjectText(const File &file, Platform &platform, raw_ostream &out) {
// Figure what ref-name labels are needed
RefNameBuilder rnb(file);