[llvm-commits] [lld] r171531 - in /lld/trunk: include/lld/Core/DefinedAtom.h include/lld/Core/File.h include/lld/Core/Pass.h lib/Core/SymbolTable.cpp tools/lld-core/TestingHelpers.hpp
Michael J. Spencer
bigcheesegs at gmail.com
Fri Jan 4 13:18:35 PST 2013
Author: mspencer
Date: Fri Jan 4 15:18:34 2013
New Revision: 171531
URL: http://llvm.org/viewvc/llvm-project?rev=171531&view=rev
Log:
Style fixes.
Modified:
lld/trunk/include/lld/Core/DefinedAtom.h
lld/trunk/include/lld/Core/File.h
lld/trunk/include/lld/Core/Pass.h
lld/trunk/lib/Core/SymbolTable.cpp
lld/trunk/tools/lld-core/TestingHelpers.hpp
Modified: lld/trunk/include/lld/Core/DefinedAtom.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/DefinedAtom.h?rev=171531&r1=171530&r2=171531&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/DefinedAtom.h (original)
+++ lld/trunk/include/lld/Core/DefinedAtom.h Fri Jan 4 15:18:34 2013
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLD_CORE_DEFINED_ATOM_H_
-#define LLD_CORE_DEFINED_ATOM_H_
+#ifndef LLD_CORE_DEFINED_ATOM_H
+#define LLD_CORE_DEFINED_ATOM_H
#include "lld/Core/Atom.h"
#include "lld/Core/Reference.h"
@@ -16,18 +16,18 @@
namespace llvm {
template <typename T>
class ArrayRef;
-
class StringRef;
}
namespace lld {
-
class File;
-/// An atom is the fundamental unit of linking. A C function or global variable
-/// is an atom. An atom has content and attributes. The content of a function
-/// atom is the instructions that implement the function. The content of a
-/// global variable atom is its initial bytes.
+/// \brief The fundamental unit of linking.
+///
+/// A C function or global variable is an atom. An atom has content and
+/// attributes. The content of a function atom is the instructions that
+/// implement the function. The content of a global variable atom is its
+/// initial bytes.
///
/// Here are some example attribute sets for common atoms. If a particular
/// attribute is not listed, the default values are: definition=regular,
@@ -175,69 +175,72 @@
uint16_t modulus;
};
- /// ordinal - returns a value for the order of this Atom within its file.
- /// This is used by the linker to order the layout of Atoms so that
- /// the resulting image is stable and reproducible.
+ /// \brief returns a value for the order of this Atom within its file.
+ ///
+ /// This is used by the linker to order the layout of Atoms so that the
+ /// resulting image is stable and reproducible.
virtual uint64_t ordinal() const = 0;
- /// size - the number of bytes of space this atom's content will occupy
- /// in the final linked image. For a function atom, it is the number
- /// of bytes of code in the function.
+ /// \brief the number of bytes of space this atom's content will occupy in the
+ /// final linked image.
+ ///
+ /// For a function atom, it is the number of bytes of code in the function.
virtual uint64_t size() const = 0;
- /// scope - The visibility of this atom to other atoms. C static functions
- /// have scope scopeTranslationUnit. Regular C functions have scope
- /// scopeGlobal. Functions compiled with visibility=hidden have scope
- /// scopeLinkageUnit so they can be see by other atoms being linked but not
- /// by the OS loader.
+ /// \brief The visibility of this atom to other atoms.
+ ///
+ /// C static functions have scope scopeTranslationUnit. Regular C functions
+ /// have scope scopeGlobal. Functions compiled with visibility=hidden have
+ /// scope scopeLinkageUnit so they can be see by other atoms being linked but
+ /// not by the OS loader.
virtual Scope scope() const = 0;
- /// interposable - Whether the linker should use direct or indirect
- /// access to this atom.
+ /// \brief Whether the linker should use direct or indirect access to this
+ /// atom.
virtual Interposable interposable() const = 0;
- /// merge - how the linker should handle if multiple atoms have
- /// the same name.
+ /// \brief how the linker should handle if multiple atoms have the same name.
virtual Merge merge() const = 0;
- /// contentType - The type of this atom, such as code or data.
+ /// \brief The type of this atom, such as code or data.
virtual ContentType contentType() const = 0;
- /// alignment - The alignment constraints on how this atom must be laid out
- /// in the final linked image (e.g. 16-byte aligned).
+ /// \brief The alignment constraints on how this atom must be laid out in the
+ /// final linked image (e.g. 16-byte aligned).
virtual Alignment alignment() const = 0;
- /// sectionChoice - Whether this atom must be in a specially named section
- /// in the final linked image, or if the linker can infer the section
- /// based on the contentType().
+ /// \brief Whether this atom must be in a specially named section in the final
+ /// linked image, or if the linker can infer the section based on the
+ /// contentType().
virtual SectionChoice sectionChoice() const = 0;
- /// customSectionName - If sectionChoice() != sectionBasedOnContent, then
- /// this return the name of the section the atom should be placed into.
+ /// \brief If sectionChoice() != sectionBasedOnContent, then this return the
+ /// name of the section the atom should be placed into.
virtual StringRef customSectionName() const = 0;
- /// deadStrip - constraints on whether the linker may dead strip away
- /// this atom.
+ /// \brief constraints on whether the linker may dead strip away this atom.
virtual DeadStripKind deadStrip() const = 0;
- /// permissions - Returns the OS memory protections required for this atom's
- /// content at runtime. A function atom is R_X, a global variable is RW_,
- /// and a read-only constant is R__.
+ /// \brief Returns the OS memory protections required for this atom's content
+ /// at runtime.
+ ///
+ /// A function atom is R_X, a global variable is RW_, and a read-only constant
+ /// is R__.
virtual ContentPermissions permissions() const = 0;
- /// isThumb - only applicable to ARM code. Tells the linker if the code
- /// uses thumb or arm instructions. The linker needs to know this to
- /// set the low bit of pointers to thumb functions.
+ /// \brief only applicable to ARM code. Tells the linker if the code uses
+ /// thumb or arm instructions. The linker needs to know this to set the low
+ /// bit of pointers to thumb functions.
virtual bool isThumb() const = 0;
- /// isAlias - means this is a zero size atom that exists to provide an
- /// alternate name for another atom. Alias atoms must have a special
- /// Reference to the atom they alias which the layout engine recognizes
- /// and forces the alias atom to layout right before the target atom.
+ /// \brief means this is a zero size atom that exists to provide an alternate
+ /// name for another atom. Alias atoms must have a special Reference to the
+ /// atom they alias which the layout engine recognizes and forces the alias
+ /// atom to layout right before the target atom.
virtual bool isAlias() const = 0;
- /// rawContent - returns a reference to the raw (unrelocated) bytes of
- /// this Atom's content.
+ /// \brief returns a reference to the raw (unrelocated) bytes of this Atom's
+ /// content.
virtual ArrayRef<uint8_t> rawContent() const = 0;
/// This class abstracts iterating over the sequence of References
@@ -245,62 +248,59 @@
/// the derefIterator() and incrementIterator() methods.
class reference_iterator {
public:
- reference_iterator(const DefinedAtom& a, const void* it)
- : _atom(a), _it(it) { }
+ reference_iterator(const DefinedAtom &a, const void *it)
+ : _atom(a), _it(it) { }
- const Reference* operator*() const {
+ const Reference *operator*() const {
return _atom.derefIterator(_it);
}
- const Reference* operator->() const {
+ const Reference *operator->() const {
return _atom.derefIterator(_it);
}
- bool operator!=(const reference_iterator& other) const {
- return (this->_it != other._it);
+ bool operator!=(const reference_iterator &other) const {
+ return _it != other._it;
}
- reference_iterator& operator++() {
+ reference_iterator &operator++() {
_atom.incrementIterator(_it);
return *this;
}
private:
- const DefinedAtom& _atom;
- const void* _it;
+ const DefinedAtom &_atom;
+ const void *_it;
};
- /// Returns an iterator to the beginning of this Atom's References
+ /// \brief Returns an iterator to the beginning of this Atom's References.
virtual reference_iterator begin() const = 0;
- /// Returns an iterator to the end of this Atom's References
+ /// \brief Returns an iterator to the end of this Atom's References.
virtual reference_iterator end() const = 0;
static inline bool classof(const Atom *a) {
return a->definition() == definitionRegular;
}
- static inline bool classof(const DefinedAtom *) { return true; }
protected:
- /// DefinedAtom is an abstract base class.
- /// Only subclasses can access constructor.
+ // DefinedAtom is an abstract base class. Only subclasses can access
+ // constructor.
DefinedAtom() : Atom(definitionRegular) { }
- /// The memory for DefinedAtom objects is always managed by the owning File
- /// object. Therefore, no one but the owning File object should call
- /// delete on an Atom. In fact, some File objects may bulk allocate
- /// an array of Atoms, so they cannot be individually deleted by anyone.
+ // The memory for DefinedAtom objects is always managed by the owning File
+ // object. Therefore, no one but the owning File object should call delete on
+ // an Atom. In fact, some File objects may bulk allocate an array of Atoms,
+ // so they cannot be individually deleted by anyone.
virtual ~DefinedAtom() {}
- /// Returns a pointer to the Reference object that the abstract
+ /// \brief Returns a pointer to the Reference object that the abstract
/// iterator "points" to.
- virtual const Reference* derefIterator(const void* iter) const = 0;
-
- /// Adjusts the abstract iterator to "point" to the next Reference object
- /// for this Atom.
- virtual void incrementIterator(const void*& iter) const = 0;
+ virtual const Reference *derefIterator(const void *iter) const = 0;
+ /// \brief Adjusts the abstract iterator to "point" to the next Reference
+ /// object for this Atom.
+ virtual void incrementIterator(const void *&iter) const = 0;
};
+} // end namespace lld
-} // namespace lld
-
-#endif // LLD_CORE_DEFINED_ATOM_H_
+#endif
Modified: lld/trunk/include/lld/Core/File.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/File.h?rev=171531&r1=171530&r2=171531&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/File.h (original)
+++ lld/trunk/include/lld/Core/File.h Fri Jan 4 15:18:34 2013
@@ -20,20 +20,18 @@
#include <vector>
namespace lld {
-
-
///
-/// Every Atom is owned by some File. A common scenario is for a single
+/// Every Atom is owned by some File. A common scenario is for a single
/// object file (.o) to be parsed by some reader and produce a single
-/// File object that represents the content of that object file.
+/// File object that represents the content of that object file.
///
/// To iterate through the Atoms in a File there are four methods that
/// return collections. For instance to iterate through all the DefinedAtoms
-/// in a File object use:
+/// in a File object use:
/// for (const DefinedAtoms *atom : file->defined()) {
/// }
///
-/// The Atom objects in a File are owned by the File object. The Atom objects
+/// The Atom objects in a File are owned by the File object. The Atom objects
/// are destroyed when the File object is destroyed.
///
class File {
@@ -59,20 +57,19 @@
}
/// Returns the path of the source file used to create the object
- /// file which this (File) object represents. This information is usually
- /// parsed out of the DWARF debug information. If the source file cannot
+ /// 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 StringRef translationUnitSource() const;
-
- static inline bool classof(const File *) {
- return true;
+ static inline bool classof(const File *) {
+ return true;
}
protected:
template <typename T> class atom_iterator; // forward reference
public:
-
+
/// For use interating over DefinedAtoms in this File.
typedef atom_iterator<DefinedAtom> defined_iterator;
@@ -85,24 +82,19 @@
/// For use interating over AbsoluteAtoms in this File.
typedef atom_iterator<AbsoluteAtom> absolute_iterator;
-
-
/// Note: this method is not const. All File objects instantiated by reading
- /// an object file from disk are "const File*" objects and cannot be
+ /// an object file from disk are "const File*" objects and cannot be
/// modified. This method can only be used with temporay File objects
/// such as is seen by each Pass object when it runs.
- /// This method is *not* safe to call while iterating through this File's
- /// Atoms. A Pass should queue up any Atoms it want to add and then
+ /// This method is *not* safe to call while iterating through this File's
+ /// Atoms. A Pass should queue up any Atoms it want to add and then
/// call this method when no longer iterating over the File's Atoms.
virtual void addAtom(const Atom&) = 0;
-
-
protected:
- /// only subclasses of File can be instantiated
+ /// only subclasses of File can be instantiated
File(StringRef p) : _path(p) {}
-
/// Different object file readers may instantiate and manage atoms with
/// different data structures. This class is a collection abstraction.
/// Each concrete File instance must implement these atom_collection
@@ -117,7 +109,6 @@
virtual void next(const void*& it) const = 0;
};
-
/// The class is the iterator type used to iterate through a File's Atoms.
/// This iterator delegates the work to the associated atom_collection object.
/// There are four kinds of Atoms, so this iterator is templated on
@@ -125,14 +116,14 @@
template <typename T>
class atom_iterator {
public:
- atom_iterator(const atom_collection<T>& c, const void* it)
+ atom_iterator(const atom_collection<T>& c, const void* it)
: _collection(c), _it(it) { }
const T* operator*() const {
return _collection.deref(_it);
}
-
const T* operator->() const {
+
return _collection.deref(_it);
}
@@ -148,35 +139,35 @@
const atom_collection<T>& _collection;
const void* _it;
};
-
+
public:
- /// Must be implemented to return the atom_collection object for
+ /// Must be implemented to return the atom_collection object for
/// all DefinedAtoms in this File.
virtual const atom_collection<DefinedAtom>& defined() const = 0;
- /// Must be implemented to return the atom_collection object for
+ /// Must be implemented to return the atom_collection object for
/// all UndefinedAtomw in this File.
virtual const atom_collection<UndefinedAtom>& undefined() const = 0;
- /// Must be implemented to return the atom_collection object for
+ /// Must be implemented to return the atom_collection object for
/// all SharedLibraryAtoms in this File.
virtual const atom_collection<SharedLibraryAtom>& sharedLibrary() const = 0;
- /// Must be implemented to return the atom_collection object for
+ /// Must be implemented to return the atom_collection object for
/// all AbsoluteAtoms in this File.
virtual const atom_collection<AbsoluteAtom>& absolute() const = 0;
protected:
/// This is a convenience class for File subclasses which manage their
- /// atoms as a simple std::vector<>.
+ /// atoms as a simple std::vector<>.
template <typename T>
class atom_collection_vector : public atom_collection<T> {
public:
- virtual atom_iterator<T> begin() const {
+ virtual atom_iterator<T> begin() const {
return atom_iterator<T>(*this, reinterpret_cast<const void*>
(_atoms.data()));
}
- virtual atom_iterator<T> end() const{
+ virtual atom_iterator<T> end() const{
return atom_iterator<T>(*this, reinterpret_cast<const void*>
(_atoms.data() + _atoms.size()));
}
@@ -190,10 +181,9 @@
}
std::vector<const T*> _atoms;
};
-
+
StringRef _path;
};
-
} // namespace lld
#endif // LLD_CORE_FILE_H_
Modified: lld/trunk/include/lld/Core/Pass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Pass.h?rev=171531&r1=171530&r2=171531&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Pass.h (original)
+++ lld/trunk/include/lld/Core/Pass.h Fri Jan 4 15:18:34 2013
@@ -18,8 +18,6 @@
namespace lld {
class DefinedAtom;
-
-///
/// Once the core linking is done (which resolves references, coalesces atoms
/// and produces a complete Atom graph), the linker runs a series of passes
/// on the Atom graph. The graph is modeled as a File, which means the pass
@@ -30,26 +28,21 @@
/// actual work in it perform() method. It can iterator over Atoms in the
/// graph using the *begin()/*end() atom iterator of the File. It can add
/// new Atoms to the graph using the File's addAtom() method.
-///
-///
class Pass {
public:
virtual ~Pass() { }
- /// Do the actual work of the Pass.
- virtual void perform(File& mergedFile) = 0;
+ /// Do the actual work of the Pass.
+ virtual void perform(File &mergedFile) = 0;
protected:
// Only subclassess can be instantiated.
Pass() { }
};
-
-///
/// Pass for adding stubs (PLT entries) for calls to functions
-/// outside the linkage unit. This class is subclassed by each
+/// outside the linkage unit. This class is subclassed by each
/// file format Writer which implements the pure virtual methods.
-///
class StubsPass : public Pass {
public:
StubsPass() : Pass() {}
@@ -57,7 +50,7 @@
/// Scans all Atoms looking for call-site uses of SharedLibraryAtoms
/// and transfroms the call-site to call a stub instead using the
/// helper methods below.
- virtual void perform(File& mergedFile);
+ virtual void perform(File &mergedFile);
/// If true, the pass should use stubs for references
/// to shared library symbols. If false, the pass
@@ -65,29 +58,25 @@
/// runtime loader will use to patch the program at runtime.
virtual bool noTextRelocs() = 0;
- /// Returns whether the Reference kind is for a call site. The pass
+ /// Returns whether the Reference kind is for a call site. The pass
/// uses this to find calls that need to be indirected through a stub.
virtual bool isCallSite(Reference::Kind) = 0;
-
+
/// Returns a file format specific atom for a stub/PLT entry which contains
- /// instructions which jump to the specified atom. May be called multiple
- /// times for the same target atom, in which case this method should return
- /// the same stub atom.
- virtual const DefinedAtom* getStub(const Atom &target) = 0;
+ /// instructions which jump to the specified atom. May be called multiple
+ /// times for the same target atom, in which case this method should return
+ /// the same stub atom.
+ virtual const DefinedAtom *getStub(const Atom &target) = 0;
/// After the default implementation of perform() is done calling getStub(),
- /// it will call this method to add all the stub (and support) atoms to the
+ /// it will call this method to add all the stub (and support) atoms to the
/// master file object.
virtual void addStubAtoms(File &masterFile) = 0;
};
-
-
-///
/// Pass for adding GOT entries for pointers to functions/data
-/// outside the linkage unit. This class is subclassed by each
+/// outside the linkage unit. This class is subclassed by each
/// file format Writer which implements the pure virtual methods.
-///
class GOTPass : public Pass {
public:
GOTPass() : Pass() {}
@@ -95,7 +84,7 @@
/// Scans all Atoms looking for pointer to SharedLibraryAtoms
/// and transfroms them to a pointer to a GOT entry using the
/// helper methods below.
- virtual void perform(File& mergedFile);
+ virtual void perform(File &mergedFile);
/// If true, the pass will use GOT entries for references
/// to shared library symbols. If false, the pass
@@ -104,13 +93,13 @@
virtual bool noTextRelocs() = 0;
/// Returns whether the Reference kind is a pre-instantiated GOT access.
- /// The default implementation of perform() uses this to figure out
+ /// The default implementation of perform() uses this to figure out
/// what GOT entries to instantiate.
- virtual bool isGOTAccess(Reference::Kind, bool& canBypassGOT) = 0;
+ virtual bool isGOTAccess(Reference::Kind, bool &canBypassGOT) = 0;
- /// The file format Writer needs to alter the reference kind from a
+ /// The file format Writer needs to alter the reference kind from a
/// pre-instantiated GOT access to an actual access. If targetIsNowGOT is
- /// true, the pass has instantiated a GOT atom and altered the reference's
+ /// true, the pass has instantiated a GOT atom and altered the reference's
/// target to point to that atom. If targetIsNowGOT is false, the pass
/// determined a GOT entry is not needed because the reference site can
/// directly access the target.
@@ -118,10 +107,8 @@
/// Returns a file format specific atom for a GOT entry targeting
/// the specified atom.
- virtual const DefinedAtom* makeGOTEntry(const Atom& target) = 0;
+ virtual const DefinedAtom *makeGOTEntry(const Atom &target) = 0;
};
-
-
} // namespace lld
#endif // LLD_CORE_PASS_H_
Modified: lld/trunk/lib/Core/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/SymbolTable.cpp?rev=171531&r1=171530&r2=171531&view=diff
==============================================================================
--- lld/trunk/lib/Core/SymbolTable.cpp (original)
+++ lld/trunk/lib/Core/SymbolTable.cpp Fri Jan 4 15:18:34 2013
@@ -29,7 +29,6 @@
#include <vector>
namespace lld {
-
SymbolTable::SymbolTable(ResolverOptions &opts)
: _options(opts) {
}
@@ -90,7 +89,6 @@
return cases[first][second];
}
-
enum MergeResolution {
MCR_First,
MCR_Second,
@@ -123,7 +121,6 @@
return mergeCases[first][second];
}
-
void SymbolTable::addByName(const Atom & newAtom) {
StringRef name = newAtom.name();
const Atom *existing = this->findByName(name);
@@ -249,7 +246,6 @@
}
}
-
unsigned SymbolTable::AtomMappingInfo::getHashValue(const DefinedAtom * const atom) {
unsigned hash = atom->size();
if ( atom->contentType() != DefinedAtom::typeZeroFill ) {
@@ -264,7 +260,6 @@
return hash;
}
-
bool SymbolTable::AtomMappingInfo::isEqual(const DefinedAtom * const l,
const DefinedAtom * const r) {
if ( l == r )
@@ -287,7 +282,6 @@
return lc.equals(rc);
}
-
void SymbolTable::addByContent(const DefinedAtom & newAtom) {
AtomContentSet::iterator pos = _contentTable.find(&newAtom);
if ( pos == _contentTable.end() ) {
@@ -299,8 +293,6 @@
_replacedAtoms[&newAtom] = existing;
}
-
-
const Atom *SymbolTable::findByName(StringRef sym) {
NameToAtom::iterator pos = _nameTable.find(sym);
if (pos == _nameTable.end())
@@ -350,5 +342,4 @@
}
}
}
-
} // namespace lld
Modified: lld/trunk/tools/lld-core/TestingHelpers.hpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/tools/lld-core/TestingHelpers.hpp?rev=171531&r1=171530&r2=171531&view=diff
==============================================================================
--- lld/trunk/tools/lld-core/TestingHelpers.hpp (original)
+++ lld/trunk/tools/lld-core/TestingHelpers.hpp Fri Jan 4 15:18:34 2013
@@ -30,24 +30,22 @@
using namespace lld;
-//
-// Simple atom created by the stubs pass.
-//
+/// \brief Simple atom created by the stubs pass.
class TestingStubAtom : public DefinedAtom {
public:
TestingStubAtom(const File &F, const Atom&) : _file(F) {
static uint32_t lastOrdinal = 0;
- _ordinal = lastOrdinal++;
+ _ordinal = lastOrdinal++;
}
- virtual const File& file() const {
+ virtual const File &file() const {
return _file;
}
virtual StringRef name() const {
return StringRef();
}
-
+
virtual uint64_t ordinal() const {
return _ordinal;
}
@@ -59,92 +57,86 @@
virtual Scope scope() const {
return DefinedAtom::scopeLinkageUnit;
}
-
+
virtual Interposable interposable() const {
return DefinedAtom::interposeNo;
}
-
+
virtual Merge merge() const {
return DefinedAtom::mergeNo;
}
-
+
virtual ContentType contentType() const {
return DefinedAtom::typeStub;
}
virtual Alignment alignment() const {
- return Alignment(0,0);
+ return Alignment(0, 0);
}
-
+
virtual SectionChoice sectionChoice() const {
return DefinedAtom::sectionBasedOnContent;
}
-
+
virtual StringRef customSectionName() const {
return StringRef();
}
virtual DeadStripKind deadStrip() const {
return DefinedAtom::deadStripNormal;
}
-
+
virtual ContentPermissions permissions() const {
return DefinedAtom::permR_X;
}
-
+
virtual bool isThumb() const {
return false;
}
-
+
virtual bool isAlias() const {
return false;
}
-
+
virtual ArrayRef<uint8_t> rawContent() const {
return ArrayRef<uint8_t>();
}
-
+
virtual reference_iterator begin() const {
return reference_iterator(*this, nullptr);
}
-
+
virtual reference_iterator end() const {
return reference_iterator(*this, nullptr);
}
-
- virtual const Reference* derefIterator(const void* iter) const {
+
+ virtual const Reference *derefIterator(const void *iter) const {
return nullptr;
}
-
- virtual void incrementIterator(const void*& iter) const {
-
+
+ virtual void incrementIterator(const void *&iter) const {
}
-
+
private:
- const File& _file;
- uint32_t _ordinal;
+ const File &_file;
+ uint32_t _ordinal;
};
-
-
-
-//
-// Simple atom created by the GOT pass.
-//
+/// \brief Simple atom created by the GOT pass.
class TestingGOTAtom : public DefinedAtom {
public:
TestingGOTAtom(const File &F, const Atom&) : _file(F) {
static uint32_t lastOrdinal = 0;
- _ordinal = lastOrdinal++;
+ _ordinal = lastOrdinal++;
}
- virtual const File& file() const {
+ virtual const File &file() const {
return _file;
}
virtual StringRef name() const {
return StringRef();
}
-
+
virtual uint64_t ordinal() const {
return _ordinal;
}
@@ -156,131 +148,123 @@
virtual Scope scope() const {
return DefinedAtom::scopeLinkageUnit;
}
-
+
virtual Interposable interposable() const {
return DefinedAtom::interposeNo;
}
-
+
virtual Merge merge() const {
return DefinedAtom::mergeNo;
}
-
+
virtual ContentType contentType() const {
return DefinedAtom::typeGOT;
}
virtual Alignment alignment() const {
- return Alignment(3,0);
+ return Alignment(3, 0);
}
-
+
virtual SectionChoice sectionChoice() const {
return DefinedAtom::sectionBasedOnContent;
}
-
+
virtual StringRef customSectionName() const {
return StringRef();
}
+
virtual DeadStripKind deadStrip() const {
return DefinedAtom::deadStripNormal;
}
-
+
virtual ContentPermissions permissions() const {
return DefinedAtom::permRW_;
}
-
+
virtual bool isThumb() const {
return false;
}
-
+
virtual bool isAlias() const {
return false;
}
-
+
virtual ArrayRef<uint8_t> rawContent() const {
return ArrayRef<uint8_t>();
}
-
+
virtual reference_iterator begin() const {
return reference_iterator(*this, nullptr);
}
-
+
virtual reference_iterator end() const {
return reference_iterator(*this, nullptr);
}
-
- virtual const Reference* derefIterator(const void* iter) const {
+
+ virtual const Reference *derefIterator(const void *iter) const {
return nullptr;
}
-
- virtual void incrementIterator(const void*& iter) const {
-
+
+ virtual void incrementIterator(const void *&iter) const {
}
-
+
private:
- const File& _file;
- uint32_t _ordinal;
+ const File &_file;
+ uint32_t _ordinal;
};
-
-
class TestingPassFile : public File {
public:
TestingPassFile() : File("Testing pass") {
}
-
+
virtual void addAtom(const Atom &atom) {
- if (const DefinedAtom* defAtom = dyn_cast<DefinedAtom>(&atom)) {
+ if (const DefinedAtom *defAtom = dyn_cast<DefinedAtom>(&atom))
_definedAtoms._atoms.push_back(defAtom);
- }
- else {
- assert(0 && "atom has unknown definition kind");
- }
+ else
+ llvm_unreachable("atom has unknown definition kind");
}
-
- virtual const atom_collection<DefinedAtom>& defined() const {
+
+ virtual const atom_collection<DefinedAtom> &defined() const {
return _definedAtoms;
}
- virtual const atom_collection<UndefinedAtom>& undefined() const {
+ virtual const atom_collection<UndefinedAtom> &undefined() const {
return _undefinedAtoms;
}
- virtual const atom_collection<SharedLibraryAtom>& sharedLibrary() const {
+ virtual const atom_collection<SharedLibraryAtom> &sharedLibrary() const {
return _sharedLibraryAtoms;
}
- virtual const atom_collection<AbsoluteAtom>& absolute() const {
+ virtual const atom_collection<AbsoluteAtom> &absolute() const {
return _absoluteAtoms;
}
-
+
private:
- atom_collection_vector<DefinedAtom> _definedAtoms;
- atom_collection_vector<UndefinedAtom> _undefinedAtoms;
- atom_collection_vector<SharedLibraryAtom> _sharedLibraryAtoms;
- atom_collection_vector<AbsoluteAtom> _absoluteAtoms;
+ atom_collection_vector<DefinedAtom> _definedAtoms;
+ atom_collection_vector<UndefinedAtom> _undefinedAtoms;
+ atom_collection_vector<SharedLibraryAtom> _sharedLibraryAtoms;
+ atom_collection_vector<AbsoluteAtom> _absoluteAtoms;
};
-
-
struct TestingKindMapping {
- const char* string;
- Reference::Kind value;
- bool isBranch;
- bool isGotLoad;
- bool isGotUse;
+ const char *string;
+ Reference::Kind value;
+ bool isBranch;
+ bool isGotLoad;
+ bool isGotUse;
};
//
// Table of fixup kinds in YAML documents used for testing
//
const TestingKindMapping sKinds[] = {
- { "call32", 2, true, false, false},
- { "pcrel32", 3, false, false, false },
- { "gotLoad32", 7, false, true, true },
- { "gotUse32", 9, false, false, true },
- { "lea32wasGot", 8, false, false, false },
- { nullptr, 0, false, false, false }
+ {"call32", 2, true, false, false},
+ {"pcrel32", 3, false, false, false},
+ {"gotLoad32", 7, false, true, true},
+ {"gotUse32", 9, false, false, true},
+ {"lea32wasGot", 8, false, false, false},
+ {nullptr, 0, false, false, false}
};
-
-
class TestingStubsPass : public StubsPass {
public:
virtual bool noTextRelocs() {
@@ -288,32 +272,29 @@
}
virtual bool isCallSite(Reference::Kind kind) {
- for (const TestingKindMapping* p = sKinds; p->string != nullptr; ++p) {
- if ( kind == p->value )
+ for (const TestingKindMapping *p = sKinds; p->string != nullptr; ++p) {
+ if (kind == p->value)
return p->isBranch;
}
return false;
}
- virtual const DefinedAtom* getStub(const Atom& target) {
+ virtual const DefinedAtom *getStub(const Atom &target) {
const DefinedAtom *result = new TestingStubAtom(_file, target);
_file.addAtom(*result);
return result;
}
-
virtual void addStubAtoms(File &mergedFile) {
for (const DefinedAtom *stub : _file.defined() ) {
mergedFile.addAtom(*stub);
}
}
-
+
private:
- TestingPassFile _file;
+ TestingPassFile _file;
};
-
-
class TestingGOTPass : public GOTPass {
public:
virtual bool noTextRelocs() {
@@ -321,31 +302,30 @@
}
virtual bool isGOTAccess(Reference::Kind kind, bool &canBypassGOT) {
- for (const TestingKindMapping* p = sKinds; p->string != nullptr; ++p) {
- if ( kind == p->value ) {
+ for (const TestingKindMapping *p = sKinds; p->string != nullptr; ++p) {
+ if (kind == p->value) {
canBypassGOT = p->isGotLoad;
- return (p->isGotUse || p->isGotLoad);
+ return p->isGotUse || p->isGotLoad;
}
}
return false;
}
virtual void updateReferenceToGOT(const Reference *ref, bool targetIsNowGOT) {
- if ( targetIsNowGOT )
- (const_cast<Reference*>(ref))->setKind(3); // pcrel32
+ if (targetIsNowGOT)
+ const_cast<Reference*>(ref)->setKind(3); // pcrel32
else
- (const_cast<Reference*>(ref))->setKind(8); // lea32wasGot
+ const_cast<Reference*>(ref)->setKind(8); // lea32wasGot
}
- virtual const DefinedAtom* makeGOTEntry(const Atom &target) {
+ virtual const DefinedAtom *makeGOTEntry(const Atom &target) {
return new TestingGOTAtom(_file, target);
}
-
+
private:
- TestingPassFile _file;
+ TestingPassFile _file;
};
-
class TestingWriterOptionsYAML : public lld::WriterOptionsYAML {
public:
TestingWriterOptionsYAML(bool stubs, bool got)
@@ -353,22 +333,22 @@
}
virtual StubsPass *stubPass() const {
- if ( _doStubs )
+ if (_doStubs)
return const_cast<TestingStubsPass*>(&_stubsPass);
else
return nullptr;
}
-
+
virtual GOTPass *gotPass() const {
- if ( _doGOT )
+ if (_doGOT)
return const_cast<TestingGOTPass*>(&_gotPass);
else
return nullptr;
}
-
+
virtual StringRef kindToString(Reference::Kind value) const {
- for (const TestingKindMapping* p = sKinds; p->string != nullptr; ++p) {
- if ( value == p->value)
+ for (const TestingKindMapping *p = sKinds; p->string != nullptr; ++p) {
+ if (value == p->value)
return p->string;
}
return StringRef("???");
@@ -380,11 +360,10 @@
TestingGOTPass _gotPass;
};
-
class TestingReaderOptionsYAML : public lld::ReaderOptionsYAML {
virtual Reference::Kind kindFromString(StringRef kindName) const {
- for (const TestingKindMapping* p = sKinds; p->string != nullptr; ++p) {
- if ( kindName.equals(p->string) )
+ for (const TestingKindMapping *p = sKinds; p->string != nullptr; ++p) {
+ if (kindName.equals(p->string))
return p->value;
}
int k;
@@ -394,6 +373,4 @@
}
};
-
-
#endif // LLD_TOOLS_TESTING_HELPERS_H_
More information about the llvm-commits
mailing list