From 05a0962a50fede85aae254667d5dac1586744eb3 Mon Sep 17 00:00:00 2001 From: Martin Nowack Date: Tue, 24 May 2016 15:13:31 +0200 Subject: Clang-formated MemoryManager --- lib/Core/MemoryManager.cpp | 26 ++++++++--------- lib/Core/MemoryManager.h | 70 +++++++++++++++++++++++----------------------- 2 files changed, 46 insertions(+), 50 deletions(-) (limited to 'lib') diff --git a/lib/Core/MemoryManager.cpp b/lib/Core/MemoryManager.cpp index 560bb6f6..004ce090 100644 --- a/lib/Core/MemoryManager.cpp +++ b/lib/Core/MemoryManager.cpp @@ -53,8 +53,7 @@ llvm::cl::opt DeterministicStartAddress( /***/ MemoryManager::MemoryManager(ArrayCache *_arrayCache) - : arrayCache(_arrayCache), deterministicSpace(0), - nextFreeSlot(0), + : arrayCache(_arrayCache), deterministicSpace(0), nextFreeSlot(0), spaceSize(DeterministicAllocationSize.getValue() * 1024 * 1024) { if (DeterministicAllocation) { // Page boundary @@ -78,7 +77,7 @@ MemoryManager::MemoryManager(ArrayCache *_arrayCache) } } -MemoryManager::~MemoryManager() { +MemoryManager::~MemoryManager() { while (!objects.empty()) { MemoryObject *mo = *objects.begin(); if (!mo->isFixed && !DeterministicAllocation) @@ -95,7 +94,7 @@ MemoryObject *MemoryManager::allocate(uint64_t size, bool isLocal, bool isGlobal, const llvm::Value *allocSite, size_t alignment) { - if (size>10*1024*1024) + if (size > 10 * 1024 * 1024) klee_warning_once(0, "Large alloc: %lu bytes. KLEE may run out of memory.", size); @@ -141,7 +140,7 @@ MemoryObject *MemoryManager::allocate(uint64_t size, bool isLocal, if (!address) return 0; - + ++stats::allocations; MemoryObject *res = new MemoryObject(address, size, isLocal, isGlobal, false, allocSite, this); @@ -152,28 +151,25 @@ MemoryObject *MemoryManager::allocate(uint64_t size, bool isLocal, MemoryObject *MemoryManager::allocateFixed(uint64_t address, uint64_t size, const llvm::Value *allocSite) { #ifndef NDEBUG - for (objects_ty::iterator it = objects.begin(), ie = objects.end(); - it != ie; ++it) { + for (objects_ty::iterator it = objects.begin(), ie = objects.end(); it != ie; + ++it) { MemoryObject *mo = *it; - if (address+size > mo->address && address < mo->address+mo->size) + if (address + size > mo->address && address < mo->address + mo->size) klee_error("Trying to allocate an overlapping object"); } #endif ++stats::allocations; - MemoryObject *res = new MemoryObject(address, size, false, true, true, - allocSite, this); + MemoryObject *res = + new MemoryObject(address, size, false, true, true, allocSite, this); objects.insert(res); return res; } -void MemoryManager::deallocate(const MemoryObject *mo) { - assert(0); -} +void MemoryManager::deallocate(const MemoryObject *mo) { assert(0); } void MemoryManager::markFreed(MemoryObject *mo) { - if (objects.find(mo) != objects.end()) - { + if (objects.find(mo) != objects.end()) { if (!mo->isFixed && !DeterministicAllocation) free((void *)mo->address); objects.erase(mo); diff --git a/lib/Core/MemoryManager.h b/lib/Core/MemoryManager.h index 5c5d21ca..fc77b476 100644 --- a/lib/Core/MemoryManager.h +++ b/lib/Core/MemoryManager.h @@ -14,44 +14,44 @@ #include namespace llvm { - class Value; +class Value; } namespace klee { - class MemoryObject; - class ArrayCache; - - class MemoryManager { - private: - typedef std::set objects_ty; - objects_ty objects; - ArrayCache *const arrayCache; - - char *deterministicSpace; - char *nextFreeSlot; - size_t spaceSize; - - public: - MemoryManager(ArrayCache *arrayCache); - ~MemoryManager(); - - /** - * Returns memory object which contains a handle to real virtual process - * memory. - */ - MemoryObject *allocate(uint64_t size, bool isLocal, bool isGlobal, - const llvm::Value *allocSite, size_t alignment = 8); - MemoryObject *allocateFixed(uint64_t address, uint64_t size, - const llvm::Value *allocSite); - void deallocate(const MemoryObject *mo); - void markFreed(MemoryObject *mo); - ArrayCache *getArrayCache() const { return arrayCache; } - - /* - * Returns the size used by deterministic allocation in bytes - */ - size_t getUsedDeterministicSize(); - }; +class MemoryObject; +class ArrayCache; + +class MemoryManager { +private: + typedef std::set objects_ty; + objects_ty objects; + ArrayCache *const arrayCache; + + char *deterministicSpace; + char *nextFreeSlot; + size_t spaceSize; + +public: + MemoryManager(ArrayCache *arrayCache); + ~MemoryManager(); + + /** + * Returns memory object which contains a handle to real virtual process + * memory. + */ + MemoryObject *allocate(uint64_t size, bool isLocal, bool isGlobal, + const llvm::Value *allocSite, size_t alignment = 8); + MemoryObject *allocateFixed(uint64_t address, uint64_t size, + const llvm::Value *allocSite); + void deallocate(const MemoryObject *mo); + void markFreed(MemoryObject *mo); + ArrayCache *getArrayCache() const { return arrayCache; } + + /* + * Returns the size used by deterministic allocation in bytes + */ + size_t getUsedDeterministicSize(); +}; } // End klee namespace -- cgit 1.4.1