summaryrefslogtreecommitdiff
path: root/tools/llvm-rtdyld
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2015-10-12 00:57:29 +0000
committerDavide Italiano <davide@freebsd.org>2015-10-12 00:57:29 +0000
commitdc7bc46ccd54de9aa2f8a026bb4bd1c86d6a0d47 (patch)
tree27fcbb4e0242a67b2a9153e7d2d111b2732b2d28 /tools/llvm-rtdyld
parent6dc307b5fd9113872116a57b970c35c5637a0d8e (diff)
[llvm-rtdyld] General modernization/cleanup in preparation for (bigger) changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250004 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-rtdyld')
-rw-r--r--tools/llvm-rtdyld/llvm-rtdyld.cpp33
1 files changed, 14 insertions, 19 deletions
diff --git a/tools/llvm-rtdyld/llvm-rtdyld.cpp b/tools/llvm-rtdyld/llvm-rtdyld.cpp
index 54b5aa03d7d..1bcd8900a27 100644
--- a/tools/llvm-rtdyld/llvm-rtdyld.cpp
+++ b/tools/llvm-rtdyld/llvm-rtdyld.cpp
@@ -197,13 +197,11 @@ uint8_t *TrivialMemoryManager::allocateDataSection(uintptr_t Size,
}
void TrivialMemoryManager::invalidateInstructionCache() {
- for (int i = 0, e = FunctionMemory.size(); i != e; ++i)
- sys::Memory::InvalidateInstructionCache(FunctionMemory[i].base(),
- FunctionMemory[i].size());
+ for (auto &FM : FunctionMemory)
+ sys::Memory::InvalidateInstructionCache(FM.base(), FM.size());
- for (int i = 0, e = DataMemory.size(); i != e; ++i)
- sys::Memory::InvalidateInstructionCache(DataMemory[i].base(),
- DataMemory[i].size());
+ for (auto &DM : DataMemory)
+ sys::Memory::InvalidateInstructionCache(DM.base(), DM.size());
}
static const char *ProgramName;
@@ -240,7 +238,7 @@ static int printLineInfoForInput(bool LoadObjects, bool UseDebugObj) {
// If we don't have any input files, read from stdin.
if (!InputFileList.size())
InputFileList.push_back("-");
- for(unsigned i = 0, e = InputFileList.size(); i != e; ++i) {
+ for (auto &File : InputFileList) {
// Instantiate a dynamic linker.
TrivialMemoryManager MemMgr;
RuntimeDyld Dyld(MemMgr, MemMgr);
@@ -248,7 +246,7 @@ static int printLineInfoForInput(bool LoadObjects, bool UseDebugObj) {
// Load the input memory buffer.
ErrorOr<std::unique_ptr<MemoryBuffer>> InputBuffer =
- MemoryBuffer::getFileOrSTDIN(InputFileList[i]);
+ MemoryBuffer::getFileOrSTDIN(File);
if (std::error_code EC = InputBuffer.getError())
return Error("unable to read input: '" + EC.message() + "'");
@@ -317,11 +315,9 @@ static int printLineInfoForInput(bool LoadObjects, bool UseDebugObj) {
<< ", Addr = " << Addr << "\n";
DILineInfoTable Lines = Context->getLineInfoForAddressRange(Addr, Size);
- DILineInfoTable::iterator Begin = Lines.begin();
- DILineInfoTable::iterator End = Lines.end();
- for (DILineInfoTable::iterator It = Begin; It != End; ++It) {
- outs() << " Line info @ " << It->first - Addr << ": "
- << It->second.FileName << ", line:" << It->second.Line << "\n";
+ for (auto &D : Lines) {
+ outs() << " Line info @ " << D.first - Addr << ": "
+ << D.second.FileName << ", line:" << D.second.Line << "\n";
}
}
}
@@ -346,10 +342,10 @@ static int executeInput() {
// If we don't have any input files, read from stdin.
if (!InputFileList.size())
InputFileList.push_back("-");
- for(unsigned i = 0, e = InputFileList.size(); i != e; ++i) {
+ for (auto &File : InputFileList) {
// Load the input memory buffer.
ErrorOr<std::unique_ptr<MemoryBuffer>> InputBuffer =
- MemoryBuffer::getFileOrSTDIN(InputFileList[i]);
+ MemoryBuffer::getFileOrSTDIN(File);
if (std::error_code EC = InputBuffer.getError())
return Error("unable to read input: '" + EC.message() + "'");
ErrorOr<std::unique_ptr<ObjectFile>> MaybeObj(
@@ -381,12 +377,11 @@ static int executeInput() {
return Error("no definition for '" + EntryPoint + "'");
// Invalidate the instruction cache for each loaded function.
- for (unsigned i = 0, e = MemMgr.FunctionMemory.size(); i != e; ++i) {
- sys::MemoryBlock &Data = MemMgr.FunctionMemory[i];
+ for (auto &FM : MemMgr.FunctionMemory) {
// Make sure the memory is executable.
std::string ErrorStr;
- sys::Memory::InvalidateInstructionCache(Data.base(), Data.size());
- if (!sys::Memory::setExecutable(Data, &ErrorStr))
+ sys::Memory::InvalidateInstructionCache(FM.base(), FM.size());
+ if (!sys::Memory::setExecutable(FM, &ErrorStr))
return Error("unable to mark function executable: '" + ErrorStr + "'");
}