diff --git a/lld/include/lld/Core/File.h b/lld/include/lld/Core/File.h index 46d3e1b034ef..167161411bb9 100644 --- a/lld/include/lld/Core/File.h +++ b/lld/include/lld/Core/File.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLD_CORE_FILE_H_ -#define LLD_CORE_FILE_H_ +#ifndef LLD_CORE_FILE_H +#define LLD_CORE_FILE_H #include "lld/Core/AbsoluteAtom.h" #include "lld/Core/DefinedAtom.h" @@ -21,7 +21,6 @@ #include namespace lld { -/// /// 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. @@ -34,52 +33,47 @@ namespace lld { /// /// 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 { public: virtual ~File(); - /// Kinds of files that are supported. + /// \brief Kinds of files that are supported. enum Kind { kindObject, ///< object file (.o) kindSharedLibrary, ///< shared library (.so) kindArchiveLibrary, ///< archive (.a) }; - /// Returns file kind. Need for dyn_cast<> on File objects. + /// \brief Returns file kind. Need for dyn_cast<> on File objects. virtual Kind kind() const { return kindObject; } - /// For error messages and debugging, this returns the path to the file + /// \brief For error messages and debugging, this returns the path to the file /// which was used to create this object (e.g. "/tmp/foo.o"). StringRef path() const { return _path; } - /// Returns the path of the source file used to create the object + /// \brief 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 /// be ascertained, this method returns the empty string. virtual StringRef translationUnitSource() const; - static inline bool classof(const File *) { - return true; - } - public: template class atom_iterator; // forward reference - /// For use interating over DefinedAtoms in this File. + /// \brief For use interating over DefinedAtoms in this File. typedef atom_iterator defined_iterator; - /// For use interating over UndefinedAtoms in this File. + /// \brief For use interating over UndefinedAtoms in this File. typedef atom_iterator undefined_iterator; - /// For use interating over SharedLibraryAtoms in this File. + /// \brief For use interating over SharedLibraryAtoms in this File. typedef atom_iterator shared_library_iterator; - /// For use interating over AbsoluteAtoms in this File. + /// \brief For use interating over AbsoluteAtoms in this File. typedef atom_iterator absolute_iterator; /// Note: this method is not const. All File objects instantiated by reading @@ -91,7 +85,7 @@ public: /// call this method when no longer iterating over the File's Atoms. virtual void addAtom(const Atom&) = 0; - /// Different object file readers may instantiate and manage atoms with + /// \brief 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 /// methods to enable clients to interate the File's atoms. @@ -105,60 +99,60 @@ public: 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 + /// \brief 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 /// the four base Atom kinds. template class atom_iterator { public: - atom_iterator(const atom_collection& c, const void* it) + atom_iterator(const atom_collection &c, const void *it) : _collection(c), _it(it) { } - const T* operator*() const { + const T *operator*() const { return _collection.deref(_it); } - const T* operator->() const { + const T *operator->() const { return _collection.deref(_it); } - bool operator!=(const atom_iterator& other) const { + bool operator!=(const atom_iterator &other) const { return (this->_it != other._it); } - atom_iterator& operator++() { + atom_iterator &operator++() { _collection.next(_it); return *this; } private: - const atom_collection& _collection; - const void* _it; + const atom_collection &_collection; + const void *_it; }; - /// Must be implemented to return the atom_collection object for + /// \brief Must be implemented to return the atom_collection object for /// all DefinedAtoms in this File. - virtual const atom_collection& defined() const = 0; + virtual const atom_collection &defined() const = 0; - /// Must be implemented to return the atom_collection object for + /// \brief Must be implemented to return the atom_collection object for /// all UndefinedAtomw in this File. - virtual const atom_collection& undefined() const = 0; + virtual const atom_collection &undefined() const = 0; - /// Must be implemented to return the atom_collection object for + /// \brief Must be implemented to return the atom_collection object for /// all SharedLibraryAtoms in this File. - virtual const atom_collection& sharedLibrary() const = 0; + virtual const atom_collection &sharedLibrary() const = 0; - /// Must be implemented to return the atom_collection object for + /// \brief Must be implemented to return the atom_collection object for /// all AbsoluteAtoms in this File. - virtual const atom_collection& absolute() const = 0; + virtual const atom_collection &absolute() const = 0; protected: - /// only subclasses of File can be instantiated + /// \brief only subclasses of File can be instantiated File(StringRef p) : _path(p) {} - /// This is a convenience class for File subclasses which manage their + /// \brief This is a convenience class for File subclasses which manage their /// atoms as a simple std::vector<>. template class atom_collection_vector : public atom_collection { @@ -171,19 +165,19 @@ protected: return atom_iterator(*this, reinterpret_cast (_atoms.data() + _atoms.size())); } - virtual const T* deref(const void* it) const { + virtual const T *deref(const void *it) const { return *reinterpret_cast(it); } - virtual void next(const void*& it) const { - const T * const * p = reinterpret_cast(it); + virtual void next(const void *&it) const { + const T *const *p = reinterpret_cast(it); ++p; it = reinterpret_cast(p); } - std::vector _atoms; + std::vector _atoms; }; - /// This is a convenience class for File subclasses which need to return - /// an empty collection + /// \brief This is a convenience class for File subclasses which need to + /// return an empty collection. template class atom_collection_empty : public atom_collection { public: @@ -210,6 +204,6 @@ protected: StringRef _path; }; -} // namespace lld +} // end namespace lld -#endif // LLD_CORE_FILE_H_ +#endif