Also, drive-by cleaning around createFunction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188875
91177308-0d34-0410-b5e6-
96231b3b80d8
};
/// \brief Represents a function in machine code, containing MCBasicBlocks.
};
/// \brief Represents a function in machine code, containing MCBasicBlocks.
-/// MCFunctions are created using MCModule::createFunction.
+/// MCFunctions are created by MCModule.
class MCFunction {
MCFunction (const MCFunction&) LLVM_DELETED_FUNCTION;
MCFunction& operator=(const MCFunction&) LLVM_DELETED_FUNCTION;
std::string Name;
class MCFunction {
MCFunction (const MCFunction&) LLVM_DELETED_FUNCTION;
MCFunction& operator=(const MCFunction&) LLVM_DELETED_FUNCTION;
std::string Name;
+ MCModule *ParentModule;
typedef std::vector<MCBasicBlock*> BasicBlockListTy;
BasicBlockListTy Blocks;
// MCModule owns the function.
friend class MCModule;
typedef std::vector<MCBasicBlock*> BasicBlockListTy;
BasicBlockListTy Blocks;
// MCModule owns the function.
friend class MCModule;
- MCFunction(StringRef Name);
-public:
+ MCFunction(StringRef Name, MCModule *Parent);
/// \brief Create an MCBasicBlock backed by Insts and add it to this function.
/// \param Insts Sequence of straight-line code backing the basic block.
/// \returns The newly created basic block.
/// \brief Create an MCBasicBlock backed by Insts and add it to this function.
/// \param Insts Sequence of straight-line code backing the basic block.
/// \returns The newly created basic block.
namespace llvm {
class MCAtom;
namespace llvm {
class MCAtom;
class MCDataAtom;
class MCFunction;
class MCObjectDisassembler;
class MCDataAtom;
class MCFunction;
class MCObjectDisassembler;
atom_iterator atom_end() { return Atoms.end(); }
/// @}
atom_iterator atom_end() { return Atoms.end(); }
/// @}
- /// \name Create a new MCFunction.
- MCFunction *createFunction(const StringRef &Name);
+ /// \brief Create a new MCFunction.
+ MCFunction *createFunction(StringRef Name);
/// \name Access to the owned function list.
/// @{
/// \name Access to the owned function list.
/// @{
#include "llvm/MC/MCFunction.h"
#include "llvm/MC/MCAtom.h"
#include "llvm/MC/MCFunction.h"
#include "llvm/MC/MCAtom.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/MC/MCModule.h"
#include <algorithm>
using namespace llvm;
// MCFunction
#include <algorithm>
using namespace llvm;
// MCFunction
-MCFunction::MCFunction(StringRef Name)
- : Name(Name)
+MCFunction::MCFunction(StringRef Name, MCModule *Parent)
+ : Name(Name), ParentModule(Parent)
{}
MCFunction::~MCFunction() {
{}
MCFunction::~MCFunction() {
assert(*I == Atom && "Previous atom mapping was invalid!");
Atoms.erase(I);
assert(*I == Atom && "Previous atom mapping was invalid!");
Atoms.erase(I);
+ // FIXME: special case NewBegin == Atom->Begin
+
// Insert the new mapping.
AtomListTy::iterator NewI = std::lower_bound(atom_begin(), atom_end(),
NewBegin, AtomComp);
// Insert the new mapping.
AtomListTy::iterator NewI = std::lower_bound(atom_begin(), atom_end(),
NewBegin, AtomComp);
+ assert((NewI == atom_end() || (*NewI)->getBeginAddr() > Atom->End)
+ && "Offset range already occupied!");
Atoms.insert(NewI, Atom);
// Update the atom internal bounds.
Atoms.insert(NewI, Atom);
// Update the atom internal bounds.
-MCFunction *MCModule::createFunction(const StringRef &Name) {
- Functions.push_back(new MCFunction(Name));
+MCFunction *MCModule::createFunction(StringRef Name) {
+ Functions.push_back(new MCFunction(Name, this));
return Functions.back();
}
return Functions.back();
}