Steal LLVM.h from Clang. This brings in very commonly used LLVM ADT/Support

types into the lld namespace.

llvm-svn: 153963
This commit is contained in:
Michael J. Spencer 2012-04-03 18:39:40 +00:00
parent f4657d5bd7
commit e6203a57b5
23 changed files with 289 additions and 206 deletions

View File

@ -18,7 +18,7 @@ namespace lld {
class AliasAtom : public Atom {
public:
AliasAtom(llvm::StringRef nm, const Atom &target, Atom::Scope scope)
AliasAtom(StringRef nm, const Atom &target, Atom::Scope scope)
: Atom( target.definition()
, Atom::combineNever
, scope
@ -38,16 +38,16 @@ public:
return _aliasOf.file();
}
virtual bool translationUnitSource(llvm::StringRef &path) const {
virtual bool translationUnitSource(StringRef &path) const {
return _aliasOf.translationUnitSource(path);
}
virtual llvm::StringRef name() const {
virtual StringRef name() const {
return _name;
}
private:
const llvm::StringRef _name;
const StringRef _name;
const Atom &_aliasOf;
};

View File

@ -10,6 +10,8 @@
#ifndef LLD_CORE_ATOM_H_
#define LLD_CORE_ATOM_H_
#include "lld/Core/LLVM.h"
#include "llvm/Support/DataTypes.h"
#include <cassert>
@ -43,9 +45,9 @@ public:
virtual const class File& file() const = 0;
/// name - The name of the atom. For a function atom, it is the (mangled)
/// name of the function.
virtual llvm::StringRef name() const = 0;
/// name of the function.
virtual StringRef name() const = 0;
/// definition - Whether this atom is a definition or represents an undefined
/// symbol.
Definition definition() const { return _definition; };

View File

@ -247,7 +247,7 @@ public:
/// rawContent - returns a reference to the raw (unrelocated) bytes of
/// this Atom's content.
virtual llvm::ArrayRef<uint8_t> rawContent() const = 0;
virtual ArrayRef<uint8_t> rawContent() const = 0;
/// This class abstracts iterating over the sequence of References
/// in an Atom. Concrete instances of DefinedAtom must implement

View File

@ -39,7 +39,7 @@ public:
/// For error messages and debugging, this returns the path to the file
/// which was used to create this object (e.g. "/tmp/foo.o").
llvm::StringRef path() const {
StringRef path() const {
return _path;
}
@ -47,7 +47,7 @@ public:
/// file which this (File) object represents. This information is usually
/// parsed out of the DWARF debug information. If the source file cannot
/// be ascertained, this method returns the empty string.
virtual llvm::StringRef translationUnitSource() const;
virtual StringRef translationUnitSource() const;
protected:
template <typename T> class atom_iterator; // forward reference
@ -118,7 +118,7 @@ public:
protected:
/// only subclasses of File can be instantiated
File(llvm::StringRef p) : _path(p) {}
File(StringRef p) : _path(p) {}
/// Different object file readers may instantiate and manage atoms with
@ -207,7 +207,7 @@ protected:
private:
llvm::StringRef _path;
StringRef _path;
};
} // namespace lld

View File

@ -39,7 +39,7 @@ public:
virtual void forEachInitialAtom(Handler &) const = 0;
/// @brief searches libraries for name
virtual bool searchLibraries( llvm::StringRef name
virtual bool searchLibraries( StringRef name
, bool searchDylibs
, bool searchArchives
, bool dataSymbolOnly

View File

@ -0,0 +1,75 @@
//===--- LLVM.h - Import various common LLVM datatypes ----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file forward declares and imports various common LLVM datatypes that
// lld wants to use unqualified.
//
//===----------------------------------------------------------------------===//
#ifndef LLD_CORE_LLVM_H
#define LLD_CORE_LLVM_H
// This should be the only #include, force #includes of all the others on
// clients.
#include "llvm/Support/Casting.h"
namespace llvm {
// ADT's.
class StringRef;
class Twine;
template<typename T> class ArrayRef;
template<class T> class OwningPtr;
template<unsigned InternalLen> class SmallString;
template<typename T, unsigned N> class SmallVector;
template<typename T> class SmallVectorImpl;
template<typename T>
struct SaveAndRestore;
// Reference counting.
template <typename T> class IntrusiveRefCntPtr;
template <typename T> struct IntrusiveRefCntPtrInfo;
template <class Derived> class RefCountedBase;
class RefCountedBaseVPTR;
class error_code;
class raw_ostream;
// TODO: DenseMap, ...
}
namespace lld {
// Casting operators.
using llvm::isa;
using llvm::cast;
using llvm::dyn_cast;
using llvm::dyn_cast_or_null;
using llvm::cast_or_null;
// ADT's.
using llvm::StringRef;
using llvm::Twine;
using llvm::ArrayRef;
using llvm::OwningPtr;
using llvm::SmallString;
using llvm::SmallVector;
using llvm::SmallVectorImpl;
using llvm::SaveAndRestore;
// Reference counting.
using llvm::IntrusiveRefCntPtr;
using llvm::IntrusiveRefCntPtrInfo;
using llvm::RefCountedBase;
using llvm::RefCountedBaseVPTR;
using llvm::error_code;
using llvm::raw_ostream;
} // end namespace clang.
#endif

View File

@ -25,15 +25,15 @@ namespace llvm {
namespace lld {
/// parseNativeObjectFileOrSTDIN - Open the specified native object file (use
/// stdin if the path is "-") and instantiate into an lld::File object.
llvm::error_code parseNativeObjectFileOrSTDIN( llvm::StringRef path
, std::unique_ptr<File> &result);
error_code parseNativeObjectFileOrSTDIN( StringRef path
, std::unique_ptr<File> &result);
/// parseNativeObjectFile - Parse the specified native object file
/// (in a buffer) and instantiate into an lld::File object.
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);
} // namespace lld

View File

@ -23,11 +23,11 @@ namespace lld {
/// writeNativeObjectFile - writes the lld::File object in native object
/// file format to the specified file path.
int writeNativeObjectFile(const lld::File &, llvm::StringRef path);
int writeNativeObjectFile(const lld::File &, StringRef path);
/// writeNativeObjectFile - writes the lld::File object in native object
/// file format to the specified stream.
int writeNativeObjectFile(const lld::File &, llvm::raw_ostream &);
int writeNativeObjectFile(const lld::File &, raw_ostream &);
} // namespace lld

View File

@ -40,7 +40,7 @@ public:
std::vector<const DefinedAtom *>&) = 0;
/// @brief give platform a chance to resolve platform-specific undefs
virtual bool getPlatformAtoms(llvm::StringRef undefined,
virtual bool getPlatformAtoms(StringRef undefined,
std::vector<const DefinedAtom *>&) = 0;
/// @brief resolver should remove unreferenced atoms
@ -53,11 +53,11 @@ public:
virtual bool getImplicitDeadStripRoots(std::vector<const DefinedAtom *>&) = 0;
/// @brief return entry point for output file (e.g. "main") or nullptr
virtual llvm::StringRef entryPointName() = 0;
virtual StringRef entryPointName() = 0;
/// @brief for iterating must-be-defined symbols ("main" or -u command line
/// option)
typedef llvm::StringRef const *UndefinesIterator;
typedef StringRef const *UndefinesIterator;
virtual UndefinesIterator initialUndefinesBegin() const = 0;
virtual UndefinesIterator initialUndefinesEnd() const = 0;
@ -66,10 +66,10 @@ public:
virtual bool searchSharedLibrariesToOverrideTentativeDefinitions() = 0;
/// @brief if platform allows symbol to remain undefined (e.g. -r)
virtual bool allowUndefinedSymbol(llvm::StringRef name) = 0;
virtual bool allowUndefinedSymbol(StringRef name) = 0;
/// @brief for debugging dead code stripping, -why_live
virtual bool printWhyLive(llvm::StringRef name) = 0;
virtual bool printWhyLive(StringRef name) = 0;
/// When core linking finds a duplicate definition, the platform
/// can either print an error message and terminate or return with
@ -104,11 +104,11 @@ public:
/// Converts a reference kind string to a in-memory numeric value.
/// For use with parsing YAML encoded object files.
virtual Reference::Kind kindFromString(llvm::StringRef) = 0;
virtual Reference::Kind kindFromString(StringRef) = 0;
/// Converts an in-memory reference kind value to a string.
/// For use with writing YAML encoded object files.
virtual llvm::StringRef kindToString(Reference::Kind) = 0;
virtual StringRef kindToString(Reference::Kind) = 0;
/// If true, the linker will use stubs and GOT entries for
/// references to shared library symbols. If false, the linker

View File

@ -25,7 +25,7 @@ public:
/// Returns shared library name used to load it at runtime.
/// On linux that is the DT_NEEDED name.
/// On Darwin it is the LC_DYLIB_LOAD dylib name.
virtual llvm::StringRef loadName() const = 0;
virtual StringRef loadName() const = 0;
/// Returns if shared library symbol can be missing at runtime and if
/// so the loader should silently resolve address of symbol to be nullptr.

View File

@ -10,6 +10,8 @@
#ifndef LLD_CORE_SYMBOL_TABLE_H_
#define LLD_CORE_SYMBOL_TABLE_H_
#include "lld/Core/LLVM.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
@ -50,10 +52,10 @@ public:
/// @brief checks if name is in symbol table and if so atom is not
/// UndefinedAtom
bool isDefined(llvm::StringRef sym);
bool isDefined(StringRef sym);
/// @brief returns atom in symbol table for specified name (or nullptr)
const Atom *findByName(llvm::StringRef sym);
const Atom *findByName(StringRef sym);
/// @brief returns vector of remaining UndefinedAtoms
void undefines(std::vector<const Atom *>&);
@ -68,14 +70,14 @@ private:
typedef llvm::DenseMap<const Atom *, const Atom *> AtomToAtom;
struct StringRefMappingInfo {
static llvm::StringRef getEmptyKey() { return llvm::StringRef(); }
static llvm::StringRef getTombstoneKey() { return llvm::StringRef(" ", 0); }
static unsigned getHashValue(llvm::StringRef const val) {
static StringRef getEmptyKey() { return StringRef(); }
static StringRef getTombstoneKey() { return StringRef(" ", 0); }
static unsigned getHashValue(StringRef const val) {
return llvm::HashString(val); }
static bool isEqual(llvm::StringRef const lhs,
llvm::StringRef const rhs) { return lhs.equals(rhs); }
static bool isEqual(StringRef const lhs,
StringRef const rhs) { return lhs.equals(rhs); }
};
typedef llvm::DenseMap<llvm::StringRef, const Atom *,
typedef llvm::DenseMap<StringRef, const Atom *,
StringRefMappingInfo> NameToAtom;
struct AtomMappingInfo {

View File

@ -10,6 +10,8 @@
#ifndef LLD_CORE_YAML_READER_H_
#define LLD_CORE_YAML_READER_H_
#include "lld/Core/LLVM.h"
#include "llvm/Support/system_error.h"
#include <vector>
@ -29,16 +31,16 @@ namespace yaml {
/// parseObjectTextFileOrSTDIN - Open the specified YAML file (use stdin if
/// the path is "-") and parse into lld::File object(s) and append each to
/// the specified vector<File*>.
llvm::error_code parseObjectTextFileOrSTDIN(llvm::StringRef path
, Platform&
, std::vector<const File *>&);
error_code parseObjectTextFileOrSTDIN( StringRef path
, Platform&
, std::vector<const File *>&);
/// 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&
, std::vector<const File *>&);
error_code parseObjectText( llvm::MemoryBuffer *mb
, Platform&
, std::vector<const File *>&);
} // namespace yaml
} // namespace lld

View File

@ -10,6 +10,8 @@
#ifndef LLD_CORE_YAML_WRITER_H_
#define LLD_CORE_YAML_WRITER_H_
#include "lld/Core/LLVM.h"
#include "llvm/Support/raw_ostream.h"
namespace lld {
@ -21,7 +23,7 @@ namespace yaml {
/// writeObjectText - writes the lld::File object as in YAML
/// format to the specified stream.
void writeObjectText(const lld::File &, Platform &, llvm::raw_ostream &);
void writeObjectText(const lld::File &, Platform &, raw_ostream &);
} // namespace yaml
} // namespace lld

View File

@ -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();
}

View File

@ -40,8 +40,8 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
: _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 @@ public:
: _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 @@ public:
: _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 @@ public:
/// 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 @@ public:
// 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 @@ private:
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 @@ private:
}
// 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 @@ private:
// 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 @@ private:
// 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 @@ private:
// 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 @@ private:
}
// 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 @@ private:
// 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 @@ private:
}
// 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:
// 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 @@ inline uint64_t NativeDefinedAtomV1:: ordinal() const {
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 @@ inline const NativeAtomAttributesV1& NativeDefinedAtomV1::attributes() const {
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 @@ inline const class File& NativeUndefinedAtomV1::file() const {
return *_file;
}
inline llvm::StringRef NativeUndefinedAtomV1::name() const {
inline StringRef NativeUndefinedAtomV1::name() const {
return _file->string(_ivarData->nameOffset);
}
@ -763,11 +763,11 @@ inline const class File& NativeSharedLibraryAtomV1::file() const {
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 @@ inline const class File& NativeAbsoluteAtomV1::file() const {
return *_file;
}
inline llvm::StringRef NativeAbsoluteAtomV1::name() const {
inline StringRef NativeAbsoluteAtomV1::name() const {
return _file->string(_ivarData->nameOffset);
}
@ -803,9 +803,9 @@ inline void NativeReferenceV1::setTarget(const Atom* newAtom) {
//
// 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 @@ llvm::error_code parseNativeObjectFile(std::unique_ptr<llvm::MemoryBuffer> mb,
//
// 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())

View File

@ -58,7 +58,7 @@ public:
}
// 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 @@ private:
}
// 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 @@ private:
}
// 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 @@ private:
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 @@ private:
// 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 @@ private:
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 @@ private:
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 @@ private:
/// 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);
}

View File

@ -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 @@ public:
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 @@ void Resolver::resolveUndefines() {
_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 @@ void Resolver::resolveUndefines() {
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 @@ void Resolver::resolveUndefines() {
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 @@ void Resolver::resolveUndefines() {
// 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 @@ void Resolver::markLive(const Atom &atom, WhyLiveBackChain *previous) {
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 @@ void Resolver::deadStripOptimize() {
// 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::removeCoalescedAwayAtoms() {
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 @@ void Resolver::checkDylibSymbolCollisions() {
// 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::resolve() {
}
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");

View File

@ -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 @@ static MergeResolution mergeSelect(DefinedAtom::Merge first,
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 @@ void SymbolTable::addByName(const Atom & newAtom) {
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 @@ void SymbolTable::addByName(const Atom & newAtom) {
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 @@ void SymbolTable::addByName(const Atom & newAtom) {
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 @@ bool SymbolTable::AtomMappingInfo::isEqual(const DefinedAtom * const l,
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 @@ void SymbolTable::addByContent(const DefinedAtom & newAtom) {
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;

View File

@ -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 @@ public:
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 @@ public:
return _sectionChoice;
}
virtual llvm::StringRef customSectionName() const {
virtual StringRef customSectionName() const {
return _sectionName;
}
@ -440,11 +441,11 @@ public:
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 @@ public:
return _file;
}
virtual llvm::StringRef name() const {
virtual StringRef name() const {
return _name;
}
@ -548,11 +549,11 @@ public:
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 @@ public:
return _file;
}
virtual llvm::StringRef name() const {
virtual StringRef name() const {
return _name;
}
@ -765,12 +766,12 @@ void YAMLAtomState::setRefName(const char *n) {
}
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 @@ void YAMLAtomState::addFixup(YAMLFile *f) {
/// 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 @@ llvm::error_code parseObjectText( llvm::MemoryBuffer *mb
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 @@ llvm::error_code parseObjectText( llvm::MemoryBuffer *mb
}
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 @@ llvm::error_code parseObjectText( llvm::MemoryBuffer *mb
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 @@ llvm::error_code parseObjectText( llvm::MemoryBuffer *mb
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 @@ llvm::error_code parseObjectText( llvm::MemoryBuffer *mb
//
// 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

View File

@ -115,7 +115,7 @@ public:
return _refNames.count(atom);
}
llvm::StringRef refName(const Atom* atom) {
StringRef refName(const Atom *atom) {
return _refNames.find(atom)->second;
}
@ -139,7 +139,7 @@ public:
: _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 @@ public:
}
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 @@ public:
<< ":"
<< 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 @@ public:
<< "\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 @@ public:
}
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 @@ public:
}
}
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 @@ public:
}
}
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 @@ private:
/// 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);

View File

@ -33,12 +33,12 @@
#include "lld/Core/DefinedAtom.h"
#include "lld/Core/File.h"
#include "lld/Core/LLVM.h"
#include "lld/Core/Pass.h"
#include "lld/Core/Platform.h"
#include "lld/Core/Reference.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/Support/Casting.h"
namespace lld {
@ -58,7 +58,7 @@ void GOTPass::perform() {
if ( _platform.isGOTAccess(ref->kind(), canBypassGOT) ) {
const Atom* target = ref->target();
assert(target != nullptr);
const DefinedAtom* defTarget = llvm::dyn_cast<DefinedAtom>(target);
const DefinedAtom* defTarget = dyn_cast<DefinedAtom>(target);
bool replaceTargetWithGOTAtom = false;
if ( target->definition() == Atom::definitionSharedLibrary ) {
// Accesses to shared library symbols must go through GOT.

View File

@ -16,12 +16,12 @@
#include "lld/Core/DefinedAtom.h"
#include "lld/Core/File.h"
#include "lld/Core/LLVM.h"
#include "lld/Core/Pass.h"
#include "lld/Core/Platform.h"
#include "lld/Core/Reference.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/Support/Casting.h"
namespace lld {
@ -49,7 +49,7 @@ void StubsPass::perform() {
// Calls to shared libraries go through stubs.
replaceCalleeWithStub = true;
} else if (const DefinedAtom* defTarget =
llvm::dyn_cast<DefinedAtom>(target)) {
dyn_cast<DefinedAtom>(target)) {
if ( defTarget->interposable() != DefinedAtom::interposeNo ) {
// Calls to interposable functions in same linkage unit
// must also go through a stub.

View File

@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "lld/Core/Atom.h"
#include "lld/Core/LLVM.h"
#include "lld/Core/NativeReader.h"
#include "lld/Core/NativeWriter.h"
#include "lld/Core/Pass.h"
@ -29,11 +30,11 @@
using namespace lld;
static void error(llvm::Twine message) {
static void error(Twine message) {
llvm::errs() << "lld-core: " << message << ".\n";
}
static bool error(llvm::error_code ec) {
static bool error(error_code ec) {
if (ec) {
error(ec.message());
return true;
@ -59,8 +60,8 @@ public:
return _file;
}
virtual llvm::StringRef name() const {
return llvm::StringRef();
virtual StringRef name() const {
return StringRef();
}
virtual uint64_t ordinal() const {
@ -95,8 +96,8 @@ public:
return DefinedAtom::sectionBasedOnContent;
}
virtual llvm::StringRef customSectionName() const {
return llvm::StringRef();
virtual StringRef customSectionName() const {
return StringRef();
}
virtual DeadStripKind deadStrip() const {
return DefinedAtom::deadStripNormal;
@ -114,8 +115,8 @@ public:
return false;
}
virtual llvm::ArrayRef<uint8_t> rawContent() const {
return llvm::ArrayRef<uint8_t>();
virtual ArrayRef<uint8_t> rawContent() const {
return ArrayRef<uint8_t>();
}
virtual reference_iterator referencesBegin() const {
@ -158,8 +159,8 @@ public:
return _file;
}
virtual llvm::StringRef name() const {
return llvm::StringRef();
virtual StringRef name() const {
return StringRef();
}
virtual uint64_t ordinal() const {
@ -194,8 +195,8 @@ public:
return DefinedAtom::sectionBasedOnContent;
}
virtual llvm::StringRef customSectionName() const {
return llvm::StringRef();
virtual StringRef customSectionName() const {
return StringRef();
}
virtual DeadStripKind deadStrip() const {
return DefinedAtom::deadStripNormal;
@ -213,8 +214,8 @@ public:
return false;
}
virtual llvm::ArrayRef<uint8_t> rawContent() const {
return llvm::ArrayRef<uint8_t>();
virtual ArrayRef<uint8_t> rawContent() const {
return ArrayRef<uint8_t>();
}
virtual reference_iterator referencesBegin() const {
@ -263,7 +264,7 @@ public:
}
// give platform a chance to resolve platform-specific undefs
virtual bool getPlatformAtoms(llvm::StringRef undefined,
virtual bool getPlatformAtoms(StringRef undefined,
std::vector<const DefinedAtom *>&) {
return false;
}
@ -284,12 +285,12 @@ public:
}
// return entry point for output file (e.g. "main") or nullptr
virtual llvm::StringRef entryPointName() {
virtual StringRef entryPointName() {
return nullptr;
}
// for iterating must-be-defined symbols ("main" or -u command line option)
typedef llvm::StringRef const *UndefinesIterator;
typedef StringRef const *UndefinesIterator;
virtual UndefinesIterator initialUndefinesBegin() const {
return nullptr;
}
@ -307,19 +308,19 @@ public:
}
// if platform allows symbol to remain undefined (e.g. -r)
virtual bool allowUndefinedSymbol(llvm::StringRef name) {
virtual bool allowUndefinedSymbol(StringRef name) {
return true;
}
// for debugging dead code stripping, -why_live
virtual bool printWhyLive(llvm::StringRef name) {
virtual bool printWhyLive(StringRef name) {
return false;
}
virtual const Atom& handleMultipleDefinitions(const Atom& def1,
virtual const Atom& handleMultipleDefinitions(const Atom& def1,
const Atom& def2) {
llvm::report_fatal_error("symbol '"
+ llvm::Twine(def1.name())
+ Twine(def1.name())
+ "' multiply defined");
}
@ -352,7 +353,7 @@ public:
static const KindMapping _s_kindMappings[];
virtual Reference::Kind kindFromString(llvm::StringRef kindName) {
virtual Reference::Kind kindFromString(StringRef kindName) {
for (const KindMapping* p = _s_kindMappings; p->string != nullptr; ++p) {
if ( kindName.equals(p->string) )
return p->value;
@ -363,12 +364,12 @@ public:
return k;
}
virtual llvm::StringRef kindToString(Reference::Kind value) {
virtual StringRef kindToString(Reference::Kind value) {
for (const KindMapping* p = _s_kindMappings; p->string != nullptr; ++p) {
if ( value == p->value)
return p->string;
}
return llvm::StringRef("???");
return StringRef("???");
}
virtual bool noTextRelocs() {
@ -459,7 +460,7 @@ public:
}
}
virtual bool searchLibraries(llvm::StringRef name, bool searchDylibs,
virtual bool searchLibraries(StringRef name, bool searchDylibs,
bool searchArchives, bool dataSymbolOnly,
InputFiles::Handler &) const {
return false;
@ -539,7 +540,7 @@ int main(int argc, char *argv[]) {
// make unique temp .o file to put generated object file
int fd;
llvm::SmallString<128> tempPath;
SmallString<128> tempPath;
llvm::sys::fs::unique_file("temp%%%%%.o", fd, tempPath);
llvm::raw_fd_ostream binaryOut(fd, /*shouldClose=*/true);