Use error_code() instead of error_code::succes()

There is no std::error_code::success, so this removes much of the noise
in transitioning to std::error_code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209952 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-05-31 01:37:45 +00:00
parent bfe17408a9
commit 1bab2d5399
19 changed files with 139 additions and 143 deletions

View File

@@ -744,7 +744,7 @@ ELFFile<ELFT>::ELFFile(MemoryBuffer *Object, error_code &ec)
} }
} }
ec = error_code::success(); ec = error_code();
} }
// Get the symbol table index in the symtab section given a symbol // Get the symbol table index in the symtab section given a symbol

View File

@@ -163,7 +163,7 @@ public:
const_reference get() const { return const_cast<ErrorOr<T> >(this)->get(); } const_reference get() const { return const_cast<ErrorOr<T> >(this)->get(); }
error_code getError() const { error_code getError() const {
return HasError ? *getErrorStorage() : error_code::success(); return HasError ? *getErrorStorage() : error_code();
} }
pointer operator ->() { pointer operator ->() {

View File

@@ -505,7 +505,7 @@ inline error_code file_size(const Twine &Path, uint64_t &Result) {
if (EC) if (EC)
return EC; return EC;
Result = Status.getSize(); Result = Status.getSize();
return error_code::success(); return error_code();
} }
/// @brief Set the file modification and access time. /// @brief Set the file modification and access time.

View File

@@ -727,10 +727,6 @@ class error_code {
public: public:
error_code() : _val_(0), _cat_(&system_category()) {} error_code() : _val_(0), _cat_(&system_category()) {}
static error_code success() {
return error_code();
}
error_code(int _val, const error_category& _cat) error_code(int _val, const error_category& _cat)
: _val_(_val), _cat_(&_cat) {} : _val_(_val), _cat_(&_cat) {}

View File

@@ -490,7 +490,7 @@ error_code BitcodeReader::ParseAttributeBlock() {
case BitstreamEntry::Error: case BitstreamEntry::Error:
return Error(MalformedBlock); return Error(MalformedBlock);
case BitstreamEntry::EndBlock: case BitstreamEntry::EndBlock:
return error_code::success(); return error_code();
case BitstreamEntry::Record: case BitstreamEntry::Record:
// The interesting case. // The interesting case.
break; break;
@@ -619,7 +619,7 @@ error_code BitcodeReader::ParseAttrKind(uint64_t Code,
*Kind = GetAttrFromCode(Code); *Kind = GetAttrFromCode(Code);
if (*Kind == Attribute::None) if (*Kind == Attribute::None)
return Error(InvalidValue); return Error(InvalidValue);
return error_code::success(); return error_code();
} }
error_code BitcodeReader::ParseAttributeGroupBlock() { error_code BitcodeReader::ParseAttributeGroupBlock() {
@@ -640,7 +640,7 @@ error_code BitcodeReader::ParseAttributeGroupBlock() {
case BitstreamEntry::Error: case BitstreamEntry::Error:
return Error(MalformedBlock); return Error(MalformedBlock);
case BitstreamEntry::EndBlock: case BitstreamEntry::EndBlock:
return error_code::success(); return error_code();
case BitstreamEntry::Record: case BitstreamEntry::Record:
// The interesting case. // The interesting case.
break; break;
@@ -731,7 +731,7 @@ error_code BitcodeReader::ParseTypeTableBody() {
case BitstreamEntry::EndBlock: case BitstreamEntry::EndBlock:
if (NumRecords != TypeList.size()) if (NumRecords != TypeList.size())
return Error(MalformedBlock); return Error(MalformedBlock);
return error_code::success(); return error_code();
case BitstreamEntry::Record: case BitstreamEntry::Record:
// The interesting case. // The interesting case.
break; break;
@@ -947,7 +947,7 @@ error_code BitcodeReader::ParseValueSymbolTable() {
case BitstreamEntry::Error: case BitstreamEntry::Error:
return Error(MalformedBlock); return Error(MalformedBlock);
case BitstreamEntry::EndBlock: case BitstreamEntry::EndBlock:
return error_code::success(); return error_code();
case BitstreamEntry::Record: case BitstreamEntry::Record:
// The interesting case. // The interesting case.
break; break;
@@ -1002,7 +1002,7 @@ error_code BitcodeReader::ParseMetadata() {
case BitstreamEntry::Error: case BitstreamEntry::Error:
return Error(MalformedBlock); return Error(MalformedBlock);
case BitstreamEntry::EndBlock: case BitstreamEntry::EndBlock:
return error_code::success(); return error_code();
case BitstreamEntry::Record: case BitstreamEntry::Record:
// The interesting case. // The interesting case.
break; break;
@@ -1178,7 +1178,7 @@ error_code BitcodeReader::ResolveGlobalAndAliasInits() {
FunctionPrefixWorklist.pop_back(); FunctionPrefixWorklist.pop_back();
} }
return error_code::success(); return error_code();
} }
static APInt ReadWideAPInt(ArrayRef<uint64_t> Vals, unsigned TypeBits) { static APInt ReadWideAPInt(ArrayRef<uint64_t> Vals, unsigned TypeBits) {
@@ -1212,7 +1212,7 @@ error_code BitcodeReader::ParseConstants() {
// Once all the constants have been read, go through and resolve forward // Once all the constants have been read, go through and resolve forward
// references. // references.
ValueList.ResolveConstantForwardRefs(); ValueList.ResolveConstantForwardRefs();
return error_code::success(); return error_code();
case BitstreamEntry::Record: case BitstreamEntry::Record:
// The interesting case. // The interesting case.
break; break;
@@ -1642,7 +1642,7 @@ error_code BitcodeReader::ParseUseLists() {
case BitstreamEntry::Error: case BitstreamEntry::Error:
return Error(MalformedBlock); return Error(MalformedBlock);
case BitstreamEntry::EndBlock: case BitstreamEntry::EndBlock:
return error_code::success(); return error_code();
case BitstreamEntry::Record: case BitstreamEntry::Record:
// The interesting case. // The interesting case.
break; break;
@@ -1682,7 +1682,7 @@ error_code BitcodeReader::RememberAndSkipFunctionBody() {
// Skip over the function block for now. // Skip over the function block for now.
if (Stream.SkipBlock()) if (Stream.SkipBlock())
return Error(InvalidRecord); return Error(InvalidRecord);
return error_code::success(); return error_code();
} }
error_code BitcodeReader::GlobalCleanup() { error_code BitcodeReader::GlobalCleanup() {
@@ -1711,7 +1711,7 @@ error_code BitcodeReader::GlobalCleanup() {
// want lazy deserialization. // want lazy deserialization.
std::vector<std::pair<GlobalVariable*, unsigned> >().swap(GlobalInits); std::vector<std::pair<GlobalVariable*, unsigned> >().swap(GlobalInits);
std::vector<std::pair<GlobalAlias*, unsigned> >().swap(AliasInits); std::vector<std::pair<GlobalAlias*, unsigned> >().swap(AliasInits);
return error_code::success(); return error_code();
} }
error_code BitcodeReader::ParseModule(bool Resume) { error_code BitcodeReader::ParseModule(bool Resume) {
@@ -1791,7 +1791,7 @@ error_code BitcodeReader::ParseModule(bool Resume) {
// just finish the parse now. // just finish the parse now.
if (LazyStreamer && SeenValueSymbolTable) { if (LazyStreamer && SeenValueSymbolTable) {
NextUnreadBit = Stream.GetCurrentBitNo(); NextUnreadBit = Stream.GetCurrentBitNo();
return error_code::success(); return error_code();
} }
break; break;
case bitc::USELIST_BLOCK_ID: case bitc::USELIST_BLOCK_ID:
@@ -2054,7 +2054,7 @@ error_code BitcodeReader::ParseBitcodeInto(Module *M) {
// need to understand them all. // need to understand them all.
while (1) { while (1) {
if (Stream.AtEndOfStream()) if (Stream.AtEndOfStream())
return error_code::success(); return error_code();
BitstreamEntry Entry = BitstreamEntry Entry =
Stream.advance(BitstreamCursor::AF_DontAutoprocessAbbrevs); Stream.advance(BitstreamCursor::AF_DontAutoprocessAbbrevs);
@@ -2063,7 +2063,7 @@ error_code BitcodeReader::ParseBitcodeInto(Module *M) {
case BitstreamEntry::Error: case BitstreamEntry::Error:
return Error(MalformedBlock); return Error(MalformedBlock);
case BitstreamEntry::EndBlock: case BitstreamEntry::EndBlock:
return error_code::success(); return error_code();
case BitstreamEntry::SubBlock: case BitstreamEntry::SubBlock:
switch (Entry.ID) { switch (Entry.ID) {
@@ -2079,7 +2079,7 @@ error_code BitcodeReader::ParseBitcodeInto(Module *M) {
if (error_code EC = ParseModule(false)) if (error_code EC = ParseModule(false))
return EC; return EC;
if (LazyStreamer) if (LazyStreamer)
return error_code::success(); return error_code();
break; break;
default: default:
if (Stream.SkipBlock()) if (Stream.SkipBlock())
@@ -2096,7 +2096,7 @@ error_code BitcodeReader::ParseBitcodeInto(Module *M) {
if (Stream.getAbbrevIDWidth() == 2 && Entry.ID == 2 && if (Stream.getAbbrevIDWidth() == 2 && Entry.ID == 2 &&
Stream.Read(6) == 2 && Stream.Read(24) == 0xa0a0a && Stream.Read(6) == 2 && Stream.Read(24) == 0xa0a0a &&
Stream.AtEndOfStream()) Stream.AtEndOfStream())
return error_code::success(); return error_code();
return Error(InvalidRecord); return Error(InvalidRecord);
} }
@@ -2118,7 +2118,7 @@ error_code BitcodeReader::ParseModuleTriple(std::string &Triple) {
case BitstreamEntry::Error: case BitstreamEntry::Error:
return Error(MalformedBlock); return Error(MalformedBlock);
case BitstreamEntry::EndBlock: case BitstreamEntry::EndBlock:
return error_code::success(); return error_code();
case BitstreamEntry::Record: case BitstreamEntry::Record:
// The interesting case. // The interesting case.
break; break;
@@ -2161,7 +2161,7 @@ error_code BitcodeReader::ParseTriple(std::string &Triple) {
case BitstreamEntry::Error: case BitstreamEntry::Error:
return Error(MalformedBlock); return Error(MalformedBlock);
case BitstreamEntry::EndBlock: case BitstreamEntry::EndBlock:
return error_code::success(); return error_code();
case BitstreamEntry::SubBlock: case BitstreamEntry::SubBlock:
if (Entry.ID == bitc::MODULE_BLOCK_ID) if (Entry.ID == bitc::MODULE_BLOCK_ID)
@@ -2193,7 +2193,7 @@ error_code BitcodeReader::ParseMetadataAttachment() {
case BitstreamEntry::Error: case BitstreamEntry::Error:
return Error(MalformedBlock); return Error(MalformedBlock);
case BitstreamEntry::EndBlock: case BitstreamEntry::EndBlock:
return error_code::success(); return error_code();
case BitstreamEntry::Record: case BitstreamEntry::Record:
// The interesting case. // The interesting case.
break; break;
@@ -3146,7 +3146,7 @@ OutOfRecordLoop:
ValueList.shrinkTo(ModuleValueListSize); ValueList.shrinkTo(ModuleValueListSize);
MDValueList.shrinkTo(ModuleMDValueListSize); MDValueList.shrinkTo(ModuleMDValueListSize);
std::vector<BasicBlock*>().swap(FunctionBBs); std::vector<BasicBlock*>().swap(FunctionBBs);
return error_code::success(); return error_code();
} }
/// Find the function body in the bitcode stream /// Find the function body in the bitcode stream
@@ -3160,7 +3160,7 @@ error_code BitcodeReader::FindFunctionInStream(Function *F,
if (error_code EC = ParseModule(true)) if (error_code EC = ParseModule(true))
return EC; return EC;
} }
return error_code::success(); return error_code();
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@@ -3180,7 +3180,7 @@ error_code BitcodeReader::Materialize(GlobalValue *GV) {
Function *F = dyn_cast<Function>(GV); Function *F = dyn_cast<Function>(GV);
// If it's not a function or is already material, ignore the request. // If it's not a function or is already material, ignore the request.
if (!F || !F->isMaterializable()) if (!F || !F->isMaterializable())
return error_code::success(); return error_code();
DenseMap<Function*, uint64_t>::iterator DFII = DeferredFunctionInfo.find(F); DenseMap<Function*, uint64_t>::iterator DFII = DeferredFunctionInfo.find(F);
assert(DFII != DeferredFunctionInfo.end() && "Deferred function not found!"); assert(DFII != DeferredFunctionInfo.end() && "Deferred function not found!");
@@ -3208,7 +3208,7 @@ error_code BitcodeReader::Materialize(GlobalValue *GV) {
} }
} }
return error_code::success(); return error_code();
} }
bool BitcodeReader::isDematerializable(const GlobalValue *GV) const { bool BitcodeReader::isDematerializable(const GlobalValue *GV) const {
@@ -3272,7 +3272,7 @@ error_code BitcodeReader::MaterializeModule(Module *M) {
UpgradeInstWithTBAATag(InstsWithTBAATag[I]); UpgradeInstWithTBAATag(InstsWithTBAATag[I]);
UpgradeDebugInfo(*M); UpgradeDebugInfo(*M);
return error_code::success(); return error_code();
} }
error_code BitcodeReader::InitStream() { error_code BitcodeReader::InitStream() {
@@ -3301,7 +3301,7 @@ error_code BitcodeReader::InitStreamFromBuffer() {
StreamFile.reset(new BitstreamReader(BufPtr, BufEnd)); StreamFile.reset(new BitstreamReader(BufPtr, BufEnd));
Stream.init(*StreamFile); Stream.init(*StreamFile);
return error_code::success(); return error_code();
} }
error_code BitcodeReader::InitLazyStream() { error_code BitcodeReader::InitLazyStream() {
@@ -3325,7 +3325,7 @@ error_code BitcodeReader::InitLazyStream() {
Bytes->dropLeadingBytes(bitcodeStart - buf); Bytes->dropLeadingBytes(bitcodeStart - buf);
Bytes->setKnownObjectSize(bitcodeEnd - bitcodeStart); Bytes->setKnownObjectSize(bitcodeEnd - bitcodeStart);
} }
return error_code::success(); return error_code();
} }
namespace { namespace {

View File

@@ -155,7 +155,7 @@ error_code SectionMemoryManager::applyMemoryGroupPermissions(MemoryGroup &MemGro
} }
} }
return error_code::success(); return error_code();
} }
void SectionMemoryManager::invalidateInstructionCache() { void SectionMemoryManager::invalidateInstructionCache() {

View File

@@ -396,7 +396,7 @@ void Module::Dematerialize(GlobalValue *GV) {
error_code Module::materializeAll() { error_code Module::materializeAll() {
if (!Materializer) if (!Materializer)
return error_code::success(); return error_code();
return Materializer->MaterializeModule(this); return Materializer->MaterializeModule(this);
} }
@@ -405,7 +405,7 @@ error_code Module::materializeAllPermanently() {
return EC; return EC;
Materializer.reset(); Materializer.reset();
return error_code::success(); return error_code();
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

View File

@@ -179,7 +179,7 @@ error_code Archive::Child::getMemoryBuffer(std::unique_ptr<MemoryBuffer> &Result
.toStringRef(Path) .toStringRef(Path)
: Name, : Name,
false)); false));
return error_code::success(); return error_code();
} }
error_code Archive::Child::getAsBinary(std::unique_ptr<Binary> &Result, error_code Archive::Child::getAsBinary(std::unique_ptr<Binary> &Result,

View File

@@ -68,7 +68,7 @@ public:
if (Filename == "-") { if (Filename == "-") {
Fd = 0; Fd = 0;
sys::ChangeStdinToBinary(); sys::ChangeStdinToBinary();
return error_code::success(); return error_code();
} }
return sys::fs::openFileForRead(Filename, Fd); return sys::fs::openFileForRead(Filename, Fd);

View File

@@ -81,7 +81,7 @@ error_code FileOutputBuffer::create(StringRef FilePath,
if (Result) if (Result)
MappedFile.release(); MappedFile.release();
return error_code::success(); return error_code();
} }
error_code FileOutputBuffer::commit(int64_t NewSmallerSize) { error_code FileOutputBuffer::commit(int64_t NewSmallerSize) {

View File

@@ -228,7 +228,7 @@ static error_code getMemoryBufferForStream(int FD,
} while (ReadBytes != 0); } while (ReadBytes != 0);
Result.reset(MemoryBuffer::getMemBufferCopy(Buffer, BufferName)); Result.reset(MemoryBuffer::getMemBufferCopy(Buffer, BufferName));
return error_code::success(); return error_code();
} }
static error_code getFileAux(const char *Filename, static error_code getFileAux(const char *Filename,
@@ -354,7 +354,7 @@ static error_code getOpenFileImpl(int FD, const char *Filename,
Result.reset(new (NamedBufferAlloc(Filename)) MemoryBufferMMapFile( Result.reset(new (NamedBufferAlloc(Filename)) MemoryBufferMMapFile(
RequiresNullTerminator, FD, MapSize, Offset, EC)); RequiresNullTerminator, FD, MapSize, Offset, EC));
if (!EC) if (!EC)
return error_code::success(); return error_code();
} }
MemoryBuffer *Buf = MemoryBuffer::getNewUninitMemBuffer(MapSize, Filename); MemoryBuffer *Buf = MemoryBuffer::getNewUninitMemBuffer(MapSize, Filename);
@@ -394,7 +394,7 @@ static error_code getOpenFileImpl(int FD, const char *Filename,
} }
Result.swap(SB); Result.swap(SB);
return error_code::success(); return error_code();
} }
error_code MemoryBuffer::getOpenFile(int FD, const char *Filename, error_code MemoryBuffer::getOpenFile(int FD, const char *Filename,

View File

@@ -209,7 +209,7 @@ retry_random_path:
return EC; return EC;
} }
return error_code::success(); return error_code();
} }
case FS_Name: { case FS_Name: {
@@ -219,7 +219,7 @@ retry_random_path:
return EC; return EC;
if (Exists) if (Exists)
goto retry_random_path; goto retry_random_path;
return error_code::success(); return error_code();
} }
case FS_Dir: { case FS_Dir: {
@@ -228,7 +228,7 @@ retry_random_path:
goto retry_random_path; goto retry_random_path;
return EC; return EC;
} }
return error_code::success(); return error_code();
} }
} }
llvm_unreachable("Invalid Type"); llvm_unreachable("Invalid Type");
@@ -711,7 +711,7 @@ error_code getUniqueID(const Twine Path, UniqueID &Result) {
if (EC) if (EC)
return EC; return EC;
Result = Status.getUniqueID(); Result = Status.getUniqueID();
return error_code::success(); return error_code();
} }
error_code createUniqueFile(const Twine &Model, int &ResultFd, error_code createUniqueFile(const Twine &Model, int &ResultFd,
@@ -781,7 +781,7 @@ error_code make_absolute(SmallVectorImpl<char> &path) {
// Already absolute. // Already absolute.
if (rootName && rootDirectory) if (rootName && rootDirectory)
return error_code::success(); return error_code();
// All of the following conditions will need the current directory. // All of the following conditions will need the current directory.
SmallString<128> current_dir; SmallString<128> current_dir;
@@ -793,7 +793,7 @@ error_code make_absolute(SmallVectorImpl<char> &path) {
path::append(current_dir, p); path::append(current_dir, p);
// Set path to the result. // Set path to the result.
path.swap(current_dir); path.swap(current_dir);
return error_code::success(); return error_code();
} }
if (!rootName && rootDirectory) { if (!rootName && rootDirectory) {
@@ -802,7 +802,7 @@ error_code make_absolute(SmallVectorImpl<char> &path) {
path::append(curDirRootName, p); path::append(curDirRootName, p);
// Set path to the result. // Set path to the result.
path.swap(curDirRootName); path.swap(curDirRootName);
return error_code::success(); return error_code();
} }
if (rootName && !rootDirectory) { if (rootName && !rootDirectory) {
@@ -814,7 +814,7 @@ error_code make_absolute(SmallVectorImpl<char> &path) {
SmallString<128> res; SmallString<128> res;
path::append(res, pRootName, bRootDirectory, bRelativePath, pRelativePath); path::append(res, pRootName, bRootDirectory, bRelativePath, pRelativePath);
path.swap(res); path.swap(res);
return error_code::success(); return error_code();
} }
llvm_unreachable("All rootName and rootDirectory combinations should have " llvm_unreachable("All rootName and rootDirectory combinations should have "
@@ -861,7 +861,7 @@ error_code is_directory(const Twine &path, bool &result) {
if (error_code ec = status(path, st)) if (error_code ec = status(path, st))
return ec; return ec;
result = is_directory(st); result = is_directory(st);
return error_code::success(); return error_code();
} }
bool is_regular_file(file_status status) { bool is_regular_file(file_status status) {
@@ -873,7 +873,7 @@ error_code is_regular_file(const Twine &path, bool &result) {
if (error_code ec = status(path, st)) if (error_code ec = status(path, st))
return ec; return ec;
result = is_regular_file(st); result = is_regular_file(st);
return error_code::success(); return error_code();
} }
bool is_other(file_status status) { bool is_other(file_status status) {
@@ -899,13 +899,13 @@ error_code has_magic(const Twine &path, const Twine &magic, bool &result) {
if (ec == errc::value_too_large) { if (ec == errc::value_too_large) {
// Magic.size() > file_size(Path). // Magic.size() > file_size(Path).
result = false; result = false;
return error_code::success(); return error_code();
} }
return ec; return ec;
} }
result = Magic == Buffer; result = Magic == Buffer;
return error_code::success(); return error_code();
} }
/// @brief Identify the magic in magic. /// @brief Identify the magic in magic.
@@ -1047,7 +1047,7 @@ error_code identify_magic(const Twine &path, file_magic &result) {
return ec; return ec;
result = identify_magic(Magic); result = identify_magic(Magic);
return error_code::success(); return error_code();
} }
error_code directory_entry::status(file_status &result) const { error_code directory_entry::status(file_status &result) const {

View File

@@ -84,7 +84,7 @@ Memory::allocateMappedMemory(size_t NumBytes,
const MemoryBlock *const NearBlock, const MemoryBlock *const NearBlock,
unsigned PFlags, unsigned PFlags,
error_code &EC) { error_code &EC) {
EC = error_code::success(); EC = error_code();
if (NumBytes == 0) if (NumBytes == 0)
return MemoryBlock(); return MemoryBlock();
@@ -140,7 +140,7 @@ Memory::allocateMappedMemory(size_t NumBytes,
error_code error_code
Memory::releaseMappedMemory(MemoryBlock &M) { Memory::releaseMappedMemory(MemoryBlock &M) {
if (M.Address == nullptr || M.Size == 0) if (M.Address == nullptr || M.Size == 0)
return error_code::success(); return error_code();
if (0 != ::munmap(M.Address, M.Size)) if (0 != ::munmap(M.Address, M.Size))
return error_code(errno, system_category()); return error_code(errno, system_category());
@@ -148,13 +148,13 @@ Memory::releaseMappedMemory(MemoryBlock &M) {
M.Address = nullptr; M.Address = nullptr;
M.Size = 0; M.Size = 0;
return error_code::success(); return error_code();
} }
error_code error_code
Memory::protectMappedMemory(const MemoryBlock &M, unsigned Flags) { Memory::protectMappedMemory(const MemoryBlock &M, unsigned Flags) {
if (M.Address == nullptr || M.Size == 0) if (M.Address == nullptr || M.Size == 0)
return error_code::success(); return error_code();
if (!Flags) if (!Flags)
return error_code(EINVAL, generic_category()); return error_code(EINVAL, generic_category());
@@ -168,7 +168,7 @@ Memory::protectMappedMemory(const MemoryBlock &M, unsigned Flags) {
if (Flags & MF_EXEC) if (Flags & MF_EXEC)
Memory::InvalidateInstructionCache(M.Address, M.Size); Memory::InvalidateInstructionCache(M.Address, M.Size);
return error_code::success(); return error_code();
} }
/// AllocateRWX - Allocate a slab of memory with read/write/execute /// AllocateRWX - Allocate a slab of memory with read/write/execute

View File

@@ -100,7 +100,7 @@ static error_code TempDir(SmallVectorImpl<char> &result) {
result.clear(); result.clear();
StringRef d(dir); StringRef d(dir);
result.append(d.begin(), d.end()); result.append(d.begin(), d.end());
return error_code::success(); return error_code();
} }
namespace llvm { namespace llvm {
@@ -235,7 +235,7 @@ error_code current_path(SmallVectorImpl<char> &result) {
!llvm::sys::fs::status(".", DotStatus) && !llvm::sys::fs::status(".", DotStatus) &&
PWDStatus.getUniqueID() == DotStatus.getUniqueID()) { PWDStatus.getUniqueID() == DotStatus.getUniqueID()) {
result.append(pwd, pwd + strlen(pwd)); result.append(pwd, pwd + strlen(pwd));
return error_code::success(); return error_code();
} }
#ifdef MAXPATHLEN #ifdef MAXPATHLEN
@@ -257,7 +257,7 @@ error_code current_path(SmallVectorImpl<char> &result) {
} }
result.set_size(strlen(result.data())); result.set_size(strlen(result.data()));
return error_code::success(); return error_code();
} }
error_code create_directory(const Twine &path, bool IgnoreExisting) { error_code create_directory(const Twine &path, bool IgnoreExisting) {
@@ -269,7 +269,7 @@ error_code create_directory(const Twine &path, bool IgnoreExisting) {
return error_code(errno, system_category()); return error_code(errno, system_category());
} }
return error_code::success(); return error_code();
} }
error_code normalize_separators(SmallVectorImpl<char> &Path) { error_code normalize_separators(SmallVectorImpl<char> &Path) {
@@ -282,7 +282,7 @@ error_code normalize_separators(SmallVectorImpl<char> &Path) {
*PI = '/'; *PI = '/';
} }
} }
return error_code::success(); return error_code();
} }
// Note that we are using symbolic link because hard links are not supported by // Note that we are using symbolic link because hard links are not supported by
@@ -297,7 +297,7 @@ error_code create_link(const Twine &to, const Twine &from) {
if (::symlink(t.begin(), f.begin()) == -1) if (::symlink(t.begin(), f.begin()) == -1)
return error_code(errno, system_category()); return error_code(errno, system_category());
return error_code::success(); return error_code();
} }
error_code remove(const Twine &path, bool IgnoreNonExisting) { error_code remove(const Twine &path, bool IgnoreNonExisting) {
@@ -308,7 +308,7 @@ error_code remove(const Twine &path, bool IgnoreNonExisting) {
if (lstat(p.begin(), &buf) != 0) { if (lstat(p.begin(), &buf) != 0) {
if (errno != errc::no_such_file_or_directory || !IgnoreNonExisting) if (errno != errc::no_such_file_or_directory || !IgnoreNonExisting)
return error_code(errno, system_category()); return error_code(errno, system_category());
return error_code::success(); return error_code();
} }
// Note: this check catches strange situations. In all cases, LLVM should // Note: this check catches strange situations. In all cases, LLVM should
@@ -324,7 +324,7 @@ error_code remove(const Twine &path, bool IgnoreNonExisting) {
return error_code(errno, system_category()); return error_code(errno, system_category());
} }
return error_code::success(); return error_code();
} }
error_code rename(const Twine &from, const Twine &to) { error_code rename(const Twine &from, const Twine &to) {
@@ -337,7 +337,7 @@ error_code rename(const Twine &from, const Twine &to) {
if (::rename(f.begin(), t.begin()) == -1) if (::rename(f.begin(), t.begin()) == -1)
return error_code(errno, system_category()); return error_code(errno, system_category());
return error_code::success(); return error_code();
} }
error_code resize_file(const Twine &path, uint64_t size) { error_code resize_file(const Twine &path, uint64_t size) {
@@ -347,7 +347,7 @@ error_code resize_file(const Twine &path, uint64_t size) {
if (::truncate(p.begin(), size) == -1) if (::truncate(p.begin(), size) == -1)
return error_code(errno, system_category()); return error_code(errno, system_category());
return error_code::success(); return error_code();
} }
error_code exists(const Twine &path, bool &result) { error_code exists(const Twine &path, bool &result) {
@@ -361,7 +361,7 @@ error_code exists(const Twine &path, bool &result) {
} else } else
result = true; result = true;
return error_code::success(); return error_code();
} }
bool can_write(const Twine &Path) { bool can_write(const Twine &Path) {
@@ -395,7 +395,7 @@ error_code equivalent(const Twine &A, const Twine &B, bool &result) {
if (error_code ec = status(A, fsA)) return ec; if (error_code ec = status(A, fsA)) return ec;
if (error_code ec = status(B, fsB)) return ec; if (error_code ec = status(B, fsB)) return ec;
result = equivalent(fsA, fsB); result = equivalent(fsA, fsB);
return error_code::success(); return error_code();
} }
static error_code fillStatus(int StatRet, const struct stat &Status, static error_code fillStatus(int StatRet, const struct stat &Status,
@@ -429,7 +429,7 @@ static error_code fillStatus(int StatRet, const struct stat &Status,
file_status(Type, Perms, Status.st_dev, Status.st_ino, Status.st_mtime, file_status(Type, Perms, Status.st_dev, Status.st_ino, Status.st_mtime,
Status.st_uid, Status.st_gid, Status.st_size); Status.st_uid, Status.st_gid, Status.st_size);
return error_code::success(); return error_code();
} }
error_code status(const Twine &Path, file_status &Result) { error_code status(const Twine &Path, file_status &Result) {
@@ -455,7 +455,7 @@ error_code setLastModificationAndAccessTime(int FD, TimeValue Time) {
Times[1] = Times[0]; Times[1] = Times[0];
if (::futimens(FD, Times)) if (::futimens(FD, Times))
return error_code(errno, system_category()); return error_code(errno, system_category());
return error_code::success(); return error_code();
#elif defined(HAVE_FUTIMES) #elif defined(HAVE_FUTIMES)
timeval Times[2]; timeval Times[2];
Times[0].tv_sec = Time.toEpochTime(); Times[0].tv_sec = Time.toEpochTime();
@@ -463,7 +463,7 @@ error_code setLastModificationAndAccessTime(int FD, TimeValue Time) {
Times[1] = Times[0]; Times[1] = Times[0];
if (::futimes(FD, Times)) if (::futimes(FD, Times))
return error_code(errno, system_category()); return error_code(errno, system_category());
return error_code::success(); return error_code();
#else #else
#warning Missing futimes() and futimens() #warning Missing futimes() and futimens()
return make_error_code(errc::not_supported); return make_error_code(errc::not_supported);
@@ -497,7 +497,7 @@ error_code mapped_file_region::init(int FD, bool CloseFD, uint64_t Offset) {
Mapping = ::mmap(nullptr, Size, prot, flags, FD, Offset); Mapping = ::mmap(nullptr, Size, prot, flags, FD, Offset);
if (Mapping == MAP_FAILED) if (Mapping == MAP_FAILED)
return error_code(errno, system_category()); return error_code(errno, system_category());
return error_code::success(); return error_code();
} }
mapped_file_region::mapped_file_region(const Twine &path, mapped_file_region::mapped_file_region(const Twine &path,
@@ -602,7 +602,7 @@ error_code detail::directory_iterator_destruct(detail::DirIterState &it) {
::closedir(reinterpret_cast<DIR *>(it.IterationHandle)); ::closedir(reinterpret_cast<DIR *>(it.IterationHandle));
it.IterationHandle = 0; it.IterationHandle = 0;
it.CurrentEntry = directory_entry(); it.CurrentEntry = directory_entry();
return error_code::success(); return error_code();
} }
error_code detail::directory_iterator_increment(detail::DirIterState &it) { error_code detail::directory_iterator_increment(detail::DirIterState &it) {
@@ -619,7 +619,7 @@ error_code detail::directory_iterator_increment(detail::DirIterState &it) {
} else } else
return directory_iterator_destruct(it); return directory_iterator_destruct(it);
return error_code::success(); return error_code();
} }
error_code get_magic(const Twine &path, uint32_t len, error_code get_magic(const Twine &path, uint32_t len,
@@ -650,7 +650,7 @@ error_code get_magic(const Twine &path, uint32_t len,
} }
std::fclose(file); std::fclose(file);
result.set_size(size); result.set_size(size);
return error_code::success(); return error_code();
} }
error_code openFileForRead(const Twine &Name, int &ResultFD) { error_code openFileForRead(const Twine &Name, int &ResultFD) {
@@ -660,7 +660,7 @@ error_code openFileForRead(const Twine &Name, int &ResultFD) {
if (errno != EINTR) if (errno != EINTR)
return error_code(errno, system_category()); return error_code(errno, system_category());
} }
return error_code::success(); return error_code();
} }
error_code openFileForWrite(const Twine &Name, int &ResultFD, error_code openFileForWrite(const Twine &Name, int &ResultFD,
@@ -690,7 +690,7 @@ error_code openFileForWrite(const Twine &Name, int &ResultFD,
if (errno != EINTR) if (errno != EINTR)
return error_code(errno, system_category()); return error_code(errno, system_category());
} }
return error_code::success(); return error_code();
} }
} // end namespace fs } // end namespace fs

View File

@@ -195,7 +195,7 @@ error_code Process::GetArgumentVector(SmallVectorImpl<const char *> &ArgsOut,
SpecificBumpPtrAllocator<char> &) { SpecificBumpPtrAllocator<char> &) {
ArgsOut.append(ArgsIn.begin(), ArgsIn.end()); ArgsOut.append(ArgsIn.begin(), ArgsIn.end());
return error_code::success(); return error_code();
} }
bool Process::StandardInIsUserInput() { bool Process::StandardInIsUserInput() {

View File

@@ -70,7 +70,7 @@ MemoryBlock Memory::allocateMappedMemory(size_t NumBytes,
const MemoryBlock *const NearBlock, const MemoryBlock *const NearBlock,
unsigned Flags, unsigned Flags,
error_code &EC) { error_code &EC) {
EC = error_code::success(); EC = error_code();
if (NumBytes == 0) if (NumBytes == 0)
return MemoryBlock(); return MemoryBlock();
@@ -115,7 +115,7 @@ MemoryBlock Memory::allocateMappedMemory(size_t NumBytes,
error_code Memory::releaseMappedMemory(MemoryBlock &M) { error_code Memory::releaseMappedMemory(MemoryBlock &M) {
if (M.Address == 0 || M.Size == 0) if (M.Address == 0 || M.Size == 0)
return error_code::success(); return error_code();
if (!VirtualFree(M.Address, 0, MEM_RELEASE)) if (!VirtualFree(M.Address, 0, MEM_RELEASE))
return error_code(::GetLastError(), system_category()); return error_code(::GetLastError(), system_category());
@@ -123,13 +123,13 @@ error_code Memory::releaseMappedMemory(MemoryBlock &M) {
M.Address = 0; M.Address = 0;
M.Size = 0; M.Size = 0;
return error_code::success(); return error_code();
} }
error_code Memory::protectMappedMemory(const MemoryBlock &M, error_code Memory::protectMappedMemory(const MemoryBlock &M,
unsigned Flags) { unsigned Flags) {
if (M.Address == 0 || M.Size == 0) if (M.Address == 0 || M.Size == 0)
return error_code::success(); return error_code();
DWORD Protect = getWindowsProtectionFlags(Flags); DWORD Protect = getWindowsProtectionFlags(Flags);
@@ -140,7 +140,7 @@ error_code Memory::protectMappedMemory(const MemoryBlock &M,
if (Flags & MF_EXEC) if (Flags & MF_EXEC)
Memory::InvalidateInstructionCache(M.Address, M.Size); Memory::InvalidateInstructionCache(M.Address, M.Size);
return error_code::success(); return error_code();
} }
/// InvalidateInstructionCache - Before the JIT can run a block of code /// InvalidateInstructionCache - Before the JIT can run a block of code
@@ -159,7 +159,7 @@ MemoryBlock Memory::AllocateRWX(size_t NumBytes,
error_code EC; error_code EC;
MB = allocateMappedMemory(NumBytes, NearBlock, MB = allocateMappedMemory(NumBytes, NearBlock,
MF_READ|MF_WRITE|MF_EXEC, EC); MF_READ|MF_WRITE|MF_EXEC, EC);
if (EC != error_code::success() && ErrMsg) { if (EC != error_code() && ErrMsg) {
MakeErrMsg(ErrMsg, EC.message()); MakeErrMsg(ErrMsg, EC.message());
} }
return MB; return MB;
@@ -167,7 +167,7 @@ MemoryBlock Memory::AllocateRWX(size_t NumBytes,
bool Memory::ReleaseRWX(MemoryBlock &M, std::string *ErrMsg) { bool Memory::ReleaseRWX(MemoryBlock &M, std::string *ErrMsg) {
error_code EC = releaseMappedMemory(M); error_code EC = releaseMappedMemory(M);
if (EC == error_code::success()) if (EC == error_code())
return false; return false;
MakeErrMsg(ErrMsg, EC.message()); MakeErrMsg(ErrMsg, EC.message());
return true; return true;

View File

@@ -155,12 +155,12 @@ error_code create_directory(const Twine &path, bool IgnoreExisting) {
return ec; return ec;
} }
return error_code::success(); return error_code();
} }
error_code normalize_separators(SmallVectorImpl<char> &Path) { error_code normalize_separators(SmallVectorImpl<char> &Path) {
(void) Path; (void) Path;
return error_code::success(); return error_code();
} }
// We can't use symbolic links for windows. // We can't use symbolic links for windows.
@@ -180,7 +180,7 @@ error_code create_link(const Twine &to, const Twine &from) {
if (!::CreateHardLinkW(wide_from.begin(), wide_to.begin(), NULL)) if (!::CreateHardLinkW(wide_from.begin(), wide_to.begin(), NULL))
return windows_error(::GetLastError()); return windows_error(::GetLastError());
return error_code::success(); return error_code();
} }
error_code remove(const Twine &path, bool IgnoreNonExisting) { error_code remove(const Twine &path, bool IgnoreNonExisting) {
@@ -191,7 +191,7 @@ error_code remove(const Twine &path, bool IgnoreNonExisting) {
if (error_code EC = status(path, ST)) { if (error_code EC = status(path, ST)) {
if (EC != errc::no_such_file_or_directory || !IgnoreNonExisting) if (EC != errc::no_such_file_or_directory || !IgnoreNonExisting)
return EC; return EC;
return error_code::success(); return error_code();
} }
if (error_code ec = UTF8ToUTF16(path.toStringRef(path_storage), if (error_code ec = UTF8ToUTF16(path.toStringRef(path_storage),
@@ -204,14 +204,14 @@ error_code remove(const Twine &path, bool IgnoreNonExisting) {
if (EC != errc::no_such_file_or_directory || !IgnoreNonExisting) if (EC != errc::no_such_file_or_directory || !IgnoreNonExisting)
return EC; return EC;
} }
return error_code::success(); return error_code();
} }
if (!::DeleteFileW(c_str(path_utf16))) { if (!::DeleteFileW(c_str(path_utf16))) {
error_code EC = windows_error(::GetLastError()); error_code EC = windows_error(::GetLastError());
if (EC != errc::no_such_file_or_directory || !IgnoreNonExisting) if (EC != errc::no_such_file_or_directory || !IgnoreNonExisting)
return EC; return EC;
} }
return error_code::success(); return error_code();
} }
error_code rename(const Twine &from, const Twine &to) { error_code rename(const Twine &from, const Twine &to) {
@@ -227,11 +227,11 @@ error_code rename(const Twine &from, const Twine &to) {
if (error_code ec = UTF8ToUTF16(f, wide_from)) return ec; if (error_code ec = UTF8ToUTF16(f, wide_from)) return ec;
if (error_code ec = UTF8ToUTF16(t, wide_to)) return ec; if (error_code ec = UTF8ToUTF16(t, wide_to)) return ec;
error_code ec = error_code::success(); error_code ec = error_code();
for (int i = 0; i < 2000; i++) { for (int i = 0; i < 2000; i++) {
if (::MoveFileExW(wide_from.begin(), wide_to.begin(), if (::MoveFileExW(wide_from.begin(), wide_to.begin(),
MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING)) MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING))
return error_code::success(); return error_code();
ec = windows_error(::GetLastError()); ec = windows_error(::GetLastError());
if (ec != windows_error::access_denied) if (ec != windows_error::access_denied)
break; break;
@@ -283,7 +283,7 @@ error_code exists(const Twine &path, bool &result) {
result = false; result = false;
} else } else
result = true; result = true;
return error_code::success(); return error_code();
} }
bool can_write(const Twine &Path) { bool can_write(const Twine &Path) {
@@ -325,7 +325,7 @@ error_code equivalent(const Twine &A, const Twine &B, bool &result) {
if (error_code ec = status(A, fsA)) return ec; if (error_code ec = status(A, fsA)) return ec;
if (error_code ec = status(B, fsB)) return ec; if (error_code ec = status(B, fsB)) return ec;
result = equivalent(fsA, fsB); result = equivalent(fsA, fsB);
return error_code::success(); return error_code();
} }
static bool isReservedName(StringRef path) { static bool isReservedName(StringRef path) {
@@ -363,16 +363,16 @@ static error_code getStatus(HANDLE FileHandle, file_status &Result) {
if (Err != NO_ERROR) if (Err != NO_ERROR)
return windows_error(Err); return windows_error(Err);
Result = file_status(file_type::type_unknown); Result = file_status(file_type::type_unknown);
return error_code::success(); return error_code();
} }
case FILE_TYPE_DISK: case FILE_TYPE_DISK:
break; break;
case FILE_TYPE_CHAR: case FILE_TYPE_CHAR:
Result = file_status(file_type::character_file); Result = file_status(file_type::character_file);
return error_code::success(); return error_code();
case FILE_TYPE_PIPE: case FILE_TYPE_PIPE:
Result = file_status(file_type::fifo_file); Result = file_status(file_type::fifo_file);
return error_code::success(); return error_code();
} }
BY_HANDLE_FILE_INFORMATION Info; BY_HANDLE_FILE_INFORMATION Info;
@@ -388,7 +388,7 @@ static error_code getStatus(HANDLE FileHandle, file_status &Result) {
Info.ftLastWriteTime.dwLowDateTime, Info.ftLastWriteTime.dwLowDateTime,
Info.dwVolumeSerialNumber, Info.nFileSizeHigh, Info.dwVolumeSerialNumber, Info.nFileSizeHigh,
Info.nFileSizeLow, Info.nFileIndexHigh, Info.nFileIndexLow); Info.nFileSizeLow, Info.nFileIndexHigh, Info.nFileIndexLow);
return error_code::success(); return error_code();
} }
handle_status_error: handle_status_error:
@@ -410,7 +410,7 @@ error_code status(const Twine &path, file_status &result) {
StringRef path8 = path.toStringRef(path_storage); StringRef path8 = path.toStringRef(path_storage);
if (isReservedName(path8)) { if (isReservedName(path8)) {
result = file_status(file_type::character_file); result = file_status(file_type::character_file);
return error_code::success(); return error_code();
} }
if (error_code ec = UTF8ToUTF16(path8, path_utf16)) if (error_code ec = UTF8ToUTF16(path8, path_utf16))
@@ -458,7 +458,7 @@ error_code setLastModificationAndAccessTime(int FD, TimeValue Time) {
HANDLE FileHandle = reinterpret_cast<HANDLE>(_get_osfhandle(FD)); HANDLE FileHandle = reinterpret_cast<HANDLE>(_get_osfhandle(FD));
if (!SetFileTime(FileHandle, NULL, &FT, &FT)) if (!SetFileTime(FileHandle, NULL, &FT, &FT))
return windows_error(::GetLastError()); return windows_error(::GetLastError());
return error_code::success(); return error_code();
} }
error_code get_magic(const Twine &path, uint32_t len, error_code get_magic(const Twine &path, uint32_t len,
@@ -500,7 +500,7 @@ error_code get_magic(const Twine &path, uint32_t len,
} }
result.set_size(len); result.set_size(len);
return error_code::success(); return error_code();
} }
error_code mapped_file_region::init(int FD, bool CloseFD, uint64_t Offset) { error_code mapped_file_region::init(int FD, bool CloseFD, uint64_t Offset) {
@@ -584,7 +584,7 @@ error_code mapped_file_region::init(int FD, bool CloseFD, uint64_t Offset) {
_close(FileDescriptor); // Also closes FileHandle. _close(FileDescriptor); // Also closes FileHandle.
} else } else
::CloseHandle(FileHandle); ::CloseHandle(FileHandle);
return error_code::success(); return error_code();
} }
mapped_file_region::mapped_file_region(const Twine &path, mapped_file_region::mapped_file_region(const Twine &path,
@@ -753,7 +753,7 @@ error_code detail::directory_iterator_construct(detail::DirIterState &it,
path::append(directory_entry_path, directory_entry_name_utf8.str()); path::append(directory_entry_path, directory_entry_name_utf8.str());
it.CurrentEntry = directory_entry(directory_entry_path.str()); it.CurrentEntry = directory_entry(directory_entry_path.str());
return error_code::success(); return error_code();
} }
error_code detail::directory_iterator_destruct(detail::DirIterState &it) { error_code detail::directory_iterator_destruct(detail::DirIterState &it) {
@@ -762,7 +762,7 @@ error_code detail::directory_iterator_destruct(detail::DirIterState &it) {
ScopedFindHandle close(HANDLE(it.IterationHandle)); ScopedFindHandle close(HANDLE(it.IterationHandle));
it.IterationHandle = 0; it.IterationHandle = 0;
it.CurrentEntry = directory_entry(); it.CurrentEntry = directory_entry();
return error_code::success(); return error_code();
} }
error_code detail::directory_iterator_increment(detail::DirIterState &it) { error_code detail::directory_iterator_increment(detail::DirIterState &it) {
@@ -788,7 +788,7 @@ error_code detail::directory_iterator_increment(detail::DirIterState &it) {
return ec; return ec;
it.CurrentEntry.replace_filename(Twine(directory_entry_path_utf8)); it.CurrentEntry.replace_filename(Twine(directory_entry_path_utf8));
return error_code::success(); return error_code();
} }
error_code openFileForRead(const Twine &Name, int &ResultFD) { error_code openFileForRead(const Twine &Name, int &ResultFD) {
@@ -821,7 +821,7 @@ error_code openFileForRead(const Twine &Name, int &ResultFD) {
} }
ResultFD = FD; ResultFD = FD;
return error_code::success(); return error_code();
} }
error_code openFileForWrite(const Twine &Name, int &ResultFD, error_code openFileForWrite(const Twine &Name, int &ResultFD,
@@ -879,7 +879,7 @@ error_code openFileForWrite(const Twine &Name, int &ResultFD,
} }
ResultFD = FD; ResultFD = FD;
return error_code::success(); return error_code();
} }
} // end namespace fs } // end namespace fs
@@ -923,7 +923,7 @@ llvm::error_code UTF8ToUTF16(llvm::StringRef utf8,
utf16.push_back(0); utf16.push_back(0);
utf16.pop_back(); utf16.pop_back();
return llvm::error_code::success(); return llvm::error_code();
} }
llvm::error_code UTF16ToUTF8(const wchar_t *utf16, size_t utf16_len, llvm::error_code UTF16ToUTF8(const wchar_t *utf16, size_t utf16_len,
@@ -951,7 +951,7 @@ llvm::error_code UTF16ToUTF8(const wchar_t *utf16, size_t utf16_len,
utf8.push_back(0); utf8.push_back(0);
utf8.pop_back(); utf8.pop_back();
return llvm::error_code::success(); return llvm::error_code();
} }
} // end namespace windows } // end namespace windows
} // end namespace sys } // end namespace sys

View File

@@ -208,7 +208,7 @@ Process::GetArgumentVector(SmallVectorImpl<const char *> &Args,
if (ec) if (ec)
return ec; return ec;
return error_code::success(); return error_code();
} }
bool Process::StandardInIsUserInput() { bool Process::StandardInIsUserInput() {

View File

@@ -59,7 +59,7 @@ protected:
TEST_P(MappedMemoryTest, AllocAndRelease) { TEST_P(MappedMemoryTest, AllocAndRelease) {
error_code EC; error_code EC;
MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC); MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
EXPECT_NE((void*)0, M1.base()); EXPECT_NE((void*)0, M1.base());
EXPECT_LE(sizeof(int), M1.size()); EXPECT_LE(sizeof(int), M1.size());
@@ -70,11 +70,11 @@ TEST_P(MappedMemoryTest, AllocAndRelease) {
TEST_P(MappedMemoryTest, MultipleAllocAndRelease) { TEST_P(MappedMemoryTest, MultipleAllocAndRelease) {
error_code EC; error_code EC;
MemoryBlock M1 = Memory::allocateMappedMemory(16, 0, Flags, EC); MemoryBlock M1 = Memory::allocateMappedMemory(16, 0, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
MemoryBlock M2 = Memory::allocateMappedMemory(64, 0, Flags, EC); MemoryBlock M2 = Memory::allocateMappedMemory(64, 0, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
MemoryBlock M3 = Memory::allocateMappedMemory(32, 0, Flags, EC); MemoryBlock M3 = Memory::allocateMappedMemory(32, 0, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
EXPECT_NE((void*)0, M1.base()); EXPECT_NE((void*)0, M1.base());
EXPECT_LE(16U, M1.size()); EXPECT_LE(16U, M1.size());
@@ -90,7 +90,7 @@ TEST_P(MappedMemoryTest, MultipleAllocAndRelease) {
EXPECT_FALSE(Memory::releaseMappedMemory(M1)); EXPECT_FALSE(Memory::releaseMappedMemory(M1));
EXPECT_FALSE(Memory::releaseMappedMemory(M3)); EXPECT_FALSE(Memory::releaseMappedMemory(M3));
MemoryBlock M4 = Memory::allocateMappedMemory(16, 0, Flags, EC); MemoryBlock M4 = Memory::allocateMappedMemory(16, 0, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
EXPECT_NE((void*)0, M4.base()); EXPECT_NE((void*)0, M4.base());
EXPECT_LE(16U, M4.size()); EXPECT_LE(16U, M4.size());
EXPECT_FALSE(Memory::releaseMappedMemory(M4)); EXPECT_FALSE(Memory::releaseMappedMemory(M4));
@@ -105,7 +105,7 @@ TEST_P(MappedMemoryTest, BasicWrite) {
error_code EC; error_code EC;
MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC); MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
EXPECT_NE((void*)0, M1.base()); EXPECT_NE((void*)0, M1.base());
EXPECT_LE(sizeof(int), M1.size()); EXPECT_LE(sizeof(int), M1.size());
@@ -124,11 +124,11 @@ TEST_P(MappedMemoryTest, MultipleWrite) {
return; return;
error_code EC; error_code EC;
MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC); MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), 0, Flags, EC); MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), 0, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), 0, Flags, EC); MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), 0, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
EXPECT_FALSE(doesOverlap(M1, M2)); EXPECT_FALSE(doesOverlap(M1, M2));
EXPECT_FALSE(doesOverlap(M2, M3)); EXPECT_FALSE(doesOverlap(M2, M3));
@@ -160,7 +160,7 @@ TEST_P(MappedMemoryTest, MultipleWrite) {
EXPECT_FALSE(Memory::releaseMappedMemory(M3)); EXPECT_FALSE(Memory::releaseMappedMemory(M3));
MemoryBlock M4 = Memory::allocateMappedMemory(64 * sizeof(int), 0, Flags, EC); MemoryBlock M4 = Memory::allocateMappedMemory(64 * sizeof(int), 0, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
EXPECT_NE((void*)0, M4.base()); EXPECT_NE((void*)0, M4.base());
EXPECT_LE(64U * sizeof(int), M4.size()); EXPECT_LE(64U * sizeof(int), M4.size());
x = (int*)M4.base(); x = (int*)M4.base();
@@ -178,11 +178,11 @@ TEST_P(MappedMemoryTest, MultipleWrite) {
TEST_P(MappedMemoryTest, EnabledWrite) { TEST_P(MappedMemoryTest, EnabledWrite) {
error_code EC; error_code EC;
MemoryBlock M1 = Memory::allocateMappedMemory(2 * sizeof(int), 0, Flags, EC); MemoryBlock M1 = Memory::allocateMappedMemory(2 * sizeof(int), 0, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), 0, Flags, EC); MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), 0, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), 0, Flags, EC); MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), 0, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
EXPECT_NE((void*)0, M1.base()); EXPECT_NE((void*)0, M1.base());
EXPECT_LE(2U * sizeof(int), M1.size()); EXPECT_LE(2U * sizeof(int), M1.size());
@@ -217,10 +217,10 @@ TEST_P(MappedMemoryTest, EnabledWrite) {
EXPECT_EQ(6, y[6]); EXPECT_EQ(6, y[6]);
MemoryBlock M4 = Memory::allocateMappedMemory(16, 0, Flags, EC); MemoryBlock M4 = Memory::allocateMappedMemory(16, 0, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
EXPECT_NE((void*)0, M4.base()); EXPECT_NE((void*)0, M4.base());
EXPECT_LE(16U, M4.size()); EXPECT_LE(16U, M4.size());
EXPECT_EQ(error_code::success(), Memory::protectMappedMemory(M4, getTestableEquivalent(Flags))); EXPECT_EQ(error_code(), Memory::protectMappedMemory(M4, getTestableEquivalent(Flags)));
x = (int*)M4.base(); x = (int*)M4.base();
*x = 4; *x = 4;
EXPECT_EQ(4, *x); EXPECT_EQ(4, *x);
@@ -231,11 +231,11 @@ TEST_P(MappedMemoryTest, EnabledWrite) {
TEST_P(MappedMemoryTest, SuccessiveNear) { TEST_P(MappedMemoryTest, SuccessiveNear) {
error_code EC; error_code EC;
MemoryBlock M1 = Memory::allocateMappedMemory(16, 0, Flags, EC); MemoryBlock M1 = Memory::allocateMappedMemory(16, 0, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
MemoryBlock M2 = Memory::allocateMappedMemory(64, &M1, Flags, EC); MemoryBlock M2 = Memory::allocateMappedMemory(64, &M1, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
MemoryBlock M3 = Memory::allocateMappedMemory(32, &M2, Flags, EC); MemoryBlock M3 = Memory::allocateMappedMemory(32, &M2, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
EXPECT_NE((void*)0, M1.base()); EXPECT_NE((void*)0, M1.base());
EXPECT_LE(16U, M1.size()); EXPECT_LE(16U, M1.size());
@@ -257,11 +257,11 @@ TEST_P(MappedMemoryTest, DuplicateNear) {
error_code EC; error_code EC;
MemoryBlock Near((void*)(3*PageSize), 16); MemoryBlock Near((void*)(3*PageSize), 16);
MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC); MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC); MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC); MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
EXPECT_NE((void*)0, M1.base()); EXPECT_NE((void*)0, M1.base());
EXPECT_LE(16U, M1.size()); EXPECT_LE(16U, M1.size());
@@ -279,11 +279,11 @@ TEST_P(MappedMemoryTest, ZeroNear) {
error_code EC; error_code EC;
MemoryBlock Near(0, 0); MemoryBlock Near(0, 0);
MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC); MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC); MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC); MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
EXPECT_NE((void*)0, M1.base()); EXPECT_NE((void*)0, M1.base());
EXPECT_LE(16U, M1.size()); EXPECT_LE(16U, M1.size());
@@ -305,11 +305,11 @@ TEST_P(MappedMemoryTest, ZeroSizeNear) {
error_code EC; error_code EC;
MemoryBlock Near((void*)(4*PageSize), 0); MemoryBlock Near((void*)(4*PageSize), 0);
MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC); MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC); MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC); MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
EXPECT_NE((void*)0, M1.base()); EXPECT_NE((void*)0, M1.base());
EXPECT_LE(16U, M1.size()); EXPECT_LE(16U, M1.size());
@@ -331,7 +331,7 @@ TEST_P(MappedMemoryTest, UnalignedNear) {
error_code EC; error_code EC;
MemoryBlock Near((void*)(2*PageSize+5), 0); MemoryBlock Near((void*)(2*PageSize+5), 0);
MemoryBlock M1 = Memory::allocateMappedMemory(15, &Near, Flags, EC); MemoryBlock M1 = Memory::allocateMappedMemory(15, &Near, Flags, EC);
EXPECT_EQ(error_code::success(), EC); EXPECT_EQ(error_code(), EC);
EXPECT_NE((void*)0, M1.base()); EXPECT_NE((void*)0, M1.base());
EXPECT_LE(sizeof(int), M1.size()); EXPECT_LE(sizeof(int), M1.size());