llvm.org GIT mirror llvm / 1bab2d5
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 Rafael Espindola 6 years ago
19 changed file(s) with 139 addition(s) and 143 deletion(s). Raw diff Collapse all Expand all
743743 }
744744 }
745745
746 ec = error_code::success();
746 ec = error_code();
747747 }
748748
749749 // Get the symbol table index in the symtab section given a symbol
162162 const_reference get() const { return const_cast >(this)->get(); }
163163
164164 error_code getError() const {
165 return HasError ? *getErrorStorage() : error_code::success();
165 return HasError ? *getErrorStorage() : error_code();
166166 }
167167
168168 pointer operator ->() {
504504 if (EC)
505505 return EC;
506506 Result = Status.getSize();
507 return error_code::success();
507 return error_code();
508508 }
509509
510510 /// @brief Set the file modification and access time.
726726 public:
727727 error_code() : _val_(0), _cat_(&system_category()) {}
728728
729 static error_code success() {
730 return error_code();
731 }
732
733729 error_code(int _val, const error_category& _cat)
734730 : _val_(_val), _cat_(&_cat) {}
735731
489489 case BitstreamEntry::Error:
490490 return Error(MalformedBlock);
491491 case BitstreamEntry::EndBlock:
492 return error_code::success();
492 return error_code();
493493 case BitstreamEntry::Record:
494494 // The interesting case.
495495 break;
618618 *Kind = GetAttrFromCode(Code);
619619 if (*Kind == Attribute::None)
620620 return Error(InvalidValue);
621 return error_code::success();
621 return error_code();
622622 }
623623
624624 error_code BitcodeReader::ParseAttributeGroupBlock() {
639639 case BitstreamEntry::Error:
640640 return Error(MalformedBlock);
641641 case BitstreamEntry::EndBlock:
642 return error_code::success();
642 return error_code();
643643 case BitstreamEntry::Record:
644644 // The interesting case.
645645 break;
730730 case BitstreamEntry::EndBlock:
731731 if (NumRecords != TypeList.size())
732732 return Error(MalformedBlock);
733 return error_code::success();
733 return error_code();
734734 case BitstreamEntry::Record:
735735 // The interesting case.
736736 break;
946946 case BitstreamEntry::Error:
947947 return Error(MalformedBlock);
948948 case BitstreamEntry::EndBlock:
949 return error_code::success();
949 return error_code();
950950 case BitstreamEntry::Record:
951951 // The interesting case.
952952 break;
10011001 case BitstreamEntry::Error:
10021002 return Error(MalformedBlock);
10031003 case BitstreamEntry::EndBlock:
1004 return error_code::success();
1004 return error_code();
10051005 case BitstreamEntry::Record:
10061006 // The interesting case.
10071007 break;
11771177 FunctionPrefixWorklist.pop_back();
11781178 }
11791179
1180 return error_code::success();
1180 return error_code();
11811181 }
11821182
11831183 static APInt ReadWideAPInt(ArrayRef Vals, unsigned TypeBits) {
12111211 // Once all the constants have been read, go through and resolve forward
12121212 // references.
12131213 ValueList.ResolveConstantForwardRefs();
1214 return error_code::success();
1214 return error_code();
12151215 case BitstreamEntry::Record:
12161216 // The interesting case.
12171217 break;
16411641 case BitstreamEntry::Error:
16421642 return Error(MalformedBlock);
16431643 case BitstreamEntry::EndBlock:
1644 return error_code::success();
1644 return error_code();
16451645 case BitstreamEntry::Record:
16461646 // The interesting case.
16471647 break;
16811681 // Skip over the function block for now.
16821682 if (Stream.SkipBlock())
16831683 return Error(InvalidRecord);
1684 return error_code::success();
1684 return error_code();
16851685 }
16861686
16871687 error_code BitcodeReader::GlobalCleanup() {
17101710 // want lazy deserialization.
17111711 std::vector >().swap(GlobalInits);
17121712 std::vector >().swap(AliasInits);
1713 return error_code::success();
1713 return error_code();
17141714 }
17151715
17161716 error_code BitcodeReader::ParseModule(bool Resume) {
17901790 // just finish the parse now.
17911791 if (LazyStreamer && SeenValueSymbolTable) {
17921792 NextUnreadBit = Stream.GetCurrentBitNo();
1793 return error_code::success();
1793 return error_code();
17941794 }
17951795 break;
17961796 case bitc::USELIST_BLOCK_ID:
20532053 // need to understand them all.
20542054 while (1) {
20552055 if (Stream.AtEndOfStream())
2056 return error_code::success();
2056 return error_code();
20572057
20582058 BitstreamEntry Entry =
20592059 Stream.advance(BitstreamCursor::AF_DontAutoprocessAbbrevs);
20622062 case BitstreamEntry::Error:
20632063 return Error(MalformedBlock);
20642064 case BitstreamEntry::EndBlock:
2065 return error_code::success();
2065 return error_code();
20662066
20672067 case BitstreamEntry::SubBlock:
20682068 switch (Entry.ID) {
20782078 if (error_code EC = ParseModule(false))
20792079 return EC;
20802080 if (LazyStreamer)
2081 return error_code::success();
2081 return error_code();
20822082 break;
20832083 default:
20842084 if (Stream.SkipBlock())
20952095 if (Stream.getAbbrevIDWidth() == 2 && Entry.ID == 2 &&
20962096 Stream.Read(6) == 2 && Stream.Read(24) == 0xa0a0a &&
20972097 Stream.AtEndOfStream())
2098 return error_code::success();
2098 return error_code();
20992099
21002100 return Error(InvalidRecord);
21012101 }
21172117 case BitstreamEntry::Error:
21182118 return Error(MalformedBlock);
21192119 case BitstreamEntry::EndBlock:
2120 return error_code::success();
2120 return error_code();
21212121 case BitstreamEntry::Record:
21222122 // The interesting case.
21232123 break;
21602160 case BitstreamEntry::Error:
21612161 return Error(MalformedBlock);
21622162 case BitstreamEntry::EndBlock:
2163 return error_code::success();
2163 return error_code();
21642164
21652165 case BitstreamEntry::SubBlock:
21662166 if (Entry.ID == bitc::MODULE_BLOCK_ID)
21922192 case BitstreamEntry::Error:
21932193 return Error(MalformedBlock);
21942194 case BitstreamEntry::EndBlock:
2195 return error_code::success();
2195 return error_code();
21962196 case BitstreamEntry::Record:
21972197 // The interesting case.
21982198 break;
31453145 ValueList.shrinkTo(ModuleValueListSize);
31463146 MDValueList.shrinkTo(ModuleMDValueListSize);
31473147 std::vector().swap(FunctionBBs);
3148 return error_code::success();
3148 return error_code();
31493149 }
31503150
31513151 /// Find the function body in the bitcode stream
31593159 if (error_code EC = ParseModule(true))
31603160 return EC;
31613161 }
3162 return error_code::success();
3162 return error_code();
31633163 }
31643164
31653165 //===----------------------------------------------------------------------===//
31793179 Function *F = dyn_cast(GV);
31803180 // If it's not a function or is already material, ignore the request.
31813181 if (!F || !F->isMaterializable())
3182 return error_code::success();
3182 return error_code();
31833183
31843184 DenseMap::iterator DFII = DeferredFunctionInfo.find(F);
31853185 assert(DFII != DeferredFunctionInfo.end() && "Deferred function not found!");
32073207 }
32083208 }
32093209
3210 return error_code::success();
3210 return error_code();
32113211 }
32123212
32133213 bool BitcodeReader::isDematerializable(const GlobalValue *GV) const {
32713271 UpgradeInstWithTBAATag(InstsWithTBAATag[I]);
32723272
32733273 UpgradeDebugInfo(*M);
3274 return error_code::success();
3274 return error_code();
32753275 }
32763276
32773277 error_code BitcodeReader::InitStream() {
33003300 StreamFile.reset(new BitstreamReader(BufPtr, BufEnd));
33013301 Stream.init(*StreamFile);
33023302
3303 return error_code::success();
3303 return error_code();
33043304 }
33053305
33063306 error_code BitcodeReader::InitLazyStream() {
33243324 Bytes->dropLeadingBytes(bitcodeStart - buf);
33253325 Bytes->setKnownObjectSize(bitcodeEnd - bitcodeStart);
33263326 }
3327 return error_code::success();
3327 return error_code();
33283328 }
33293329
33303330 namespace {
154154 }
155155 }
156156
157 return error_code::success();
157 return error_code();
158158 }
159159
160160 void SectionMemoryManager::invalidateInstructionCache() {
395395
396396 error_code Module::materializeAll() {
397397 if (!Materializer)
398 return error_code::success();
398 return error_code();
399399 return Materializer->MaterializeModule(this);
400400 }
401401
404404 return EC;
405405
406406 Materializer.reset();
407 return error_code::success();
407 return error_code();
408408 }
409409
410410 //===----------------------------------------------------------------------===//
178178 .toStringRef(Path)
179179 : Name,
180180 false));
181 return error_code::success();
181 return error_code();
182182 }
183183
184184 error_code Archive::Child::getAsBinary(std::unique_ptr &Result,
6767 if (Filename == "-") {
6868 Fd = 0;
6969 sys::ChangeStdinToBinary();
70 return error_code::success();
70 return error_code();
7171 }
7272
7373 return sys::fs::openFileForRead(Filename, Fd);
8080 if (Result)
8181 MappedFile.release();
8282
83 return error_code::success();
83 return error_code();
8484 }
8585
8686 error_code FileOutputBuffer::commit(int64_t NewSmallerSize) {
227227 } while (ReadBytes != 0);
228228
229229 Result.reset(MemoryBuffer::getMemBufferCopy(Buffer, BufferName));
230 return error_code::success();
230 return error_code();
231231 }
232232
233233 static error_code getFileAux(const char *Filename,
353353 Result.reset(new (NamedBufferAlloc(Filename)) MemoryBufferMMapFile(
354354 RequiresNullTerminator, FD, MapSize, Offset, EC));
355355 if (!EC)
356 return error_code::success();
356 return error_code();
357357 }
358358
359359 MemoryBuffer *Buf = MemoryBuffer::getNewUninitMemBuffer(MapSize, Filename);
393393 }
394394
395395 Result.swap(SB);
396 return error_code::success();
396 return error_code();
397397 }
398398
399399 error_code MemoryBuffer::getOpenFile(int FD, const char *Filename,
208208 return EC;
209209 }
210210
211 return error_code::success();
211 return error_code();
212212 }
213213
214214 case FS_Name: {
218218 return EC;
219219 if (Exists)
220220 goto retry_random_path;
221 return error_code::success();
221 return error_code();
222222 }
223223
224224 case FS_Dir: {
227227 goto retry_random_path;
228228 return EC;
229229 }
230 return error_code::success();
230 return error_code();
231231 }
232232 }
233233 llvm_unreachable("Invalid Type");
710710 if (EC)
711711 return EC;
712712 Result = Status.getUniqueID();
713 return error_code::success();
713 return error_code();
714714 }
715715
716716 error_code createUniqueFile(const Twine &Model, int &ResultFd,
780780
781781 // Already absolute.
782782 if (rootName && rootDirectory)
783 return error_code::success();
783 return error_code();
784784
785785 // All of the following conditions will need the current directory.
786786 SmallString<128> current_dir;
792792 path::append(current_dir, p);
793793 // Set path to the result.
794794 path.swap(current_dir);
795 return error_code::success();
795 return error_code();
796796 }
797797
798798 if (!rootName && rootDirectory) {
801801 path::append(curDirRootName, p);
802802 // Set path to the result.
803803 path.swap(curDirRootName);
804 return error_code::success();
804 return error_code();
805805 }
806806
807807 if (rootName && !rootDirectory) {
813813 SmallString<128> res;
814814 path::append(res, pRootName, bRootDirectory, bRelativePath, pRelativePath);
815815 path.swap(res);
816 return error_code::success();
816 return error_code();
817817 }
818818
819819 llvm_unreachable("All rootName and rootDirectory combinations should have "
860860 if (error_code ec = status(path, st))
861861 return ec;
862862 result = is_directory(st);
863 return error_code::success();
863 return error_code();
864864 }
865865
866866 bool is_regular_file(file_status status) {
872872 if (error_code ec = status(path, st))
873873 return ec;
874874 result = is_regular_file(st);
875 return error_code::success();
875 return error_code();
876876 }
877877
878878 bool is_other(file_status status) {
898898 if (ec == errc::value_too_large) {
899899 // Magic.size() > file_size(Path).
900900 result = false;
901 return error_code::success();
901 return error_code();
902902 }
903903 return ec;
904904 }
905905
906906 result = Magic == Buffer;
907 return error_code::success();
907 return error_code();
908908 }
909909
910910 /// @brief Identify the magic in magic.
10461046 return ec;
10471047
10481048 result = identify_magic(Magic);
1049 return error_code::success();
1049 return error_code();
10501050 }
10511051
10521052 error_code directory_entry::status(file_status &result) const {
8383 const MemoryBlock *const NearBlock,
8484 unsigned PFlags,
8585 error_code &EC) {
86 EC = error_code::success();
86 EC = error_code();
8787 if (NumBytes == 0)
8888 return MemoryBlock();
8989
139139 error_code
140140 Memory::releaseMappedMemory(MemoryBlock &M) {
141141 if (M.Address == nullptr || M.Size == 0)
142 return error_code::success();
142 return error_code();
143143
144144 if (0 != ::munmap(M.Address, M.Size))
145145 return error_code(errno, system_category());
147147 M.Address = nullptr;
148148 M.Size = 0;
149149
150 return error_code::success();
150 return error_code();
151151 }
152152
153153 error_code
154154 Memory::protectMappedMemory(const MemoryBlock &M, unsigned Flags) {
155155 if (M.Address == nullptr || M.Size == 0)
156 return error_code::success();
156 return error_code();
157157
158158 if (!Flags)
159159 return error_code(EINVAL, generic_category());
167167 if (Flags & MF_EXEC)
168168 Memory::InvalidateInstructionCache(M.Address, M.Size);
169169
170 return error_code::success();
170 return error_code();
171171 }
172172
173173 /// AllocateRWX - Allocate a slab of memory with read/write/execute
9999 result.clear();
100100 StringRef d(dir);
101101 result.append(d.begin(), d.end());
102 return error_code::success();
102 return error_code();
103103 }
104104
105105 namespace llvm {
234234 !llvm::sys::fs::status(".", DotStatus) &&
235235 PWDStatus.getUniqueID() == DotStatus.getUniqueID()) {
236236 result.append(pwd, pwd + strlen(pwd));
237 return error_code::success();
237 return error_code();
238238 }
239239
240240 #ifdef MAXPATHLEN
256256 }
257257
258258 result.set_size(strlen(result.data()));
259 return error_code::success();
259 return error_code();
260260 }
261261
262262 error_code create_directory(const Twine &path, bool IgnoreExisting) {
268268 return error_code(errno, system_category());
269269 }
270270
271 return error_code::success();
271 return error_code();
272272 }
273273
274274 error_code normalize_separators(SmallVectorImpl &Path) {
281281 *PI = '/';
282282 }
283283 }
284 return error_code::success();
284 return error_code();
285285 }
286286
287287 // Note that we are using symbolic link because hard links are not supported by
296296 if (::symlink(t.begin(), f.begin()) == -1)
297297 return error_code(errno, system_category());
298298
299 return error_code::success();
299 return error_code();
300300 }
301301
302302 error_code remove(const Twine &path, bool IgnoreNonExisting) {
307307 if (lstat(p.begin(), &buf) != 0) {
308308 if (errno != errc::no_such_file_or_directory || !IgnoreNonExisting)
309309 return error_code(errno, system_category());
310 return error_code::success();
310 return error_code();
311311 }
312312
313313 // Note: this check catches strange situations. In all cases, LLVM should
323323 return error_code(errno, system_category());
324324 }
325325
326 return error_code::success();
326 return error_code();
327327 }
328328
329329 error_code rename(const Twine &from, const Twine &to) {
336336 if (::rename(f.begin(), t.begin()) == -1)
337337 return error_code(errno, system_category());
338338
339 return error_code::success();
339 return error_code();
340340 }
341341
342342 error_code resize_file(const Twine &path, uint64_t size) {
346346 if (::truncate(p.begin(), size) == -1)
347347 return error_code(errno, system_category());
348348
349 return error_code::success();
349 return error_code();
350350 }
351351
352352 error_code exists(const Twine &path, bool &result) {
360360 } else
361361 result = true;
362362
363 return error_code::success();
363 return error_code();
364364 }
365365
366366 bool can_write(const Twine &Path) {
394394 if (error_code ec = status(A, fsA)) return ec;
395395 if (error_code ec = status(B, fsB)) return ec;
396396 result = equivalent(fsA, fsB);
397 return error_code::success();
397 return error_code();
398398 }
399399
400400 static error_code fillStatus(int StatRet, const struct stat &Status,
428428 file_status(Type, Perms, Status.st_dev, Status.st_ino, Status.st_mtime,
429429 Status.st_uid, Status.st_gid, Status.st_size);
430430
431 return error_code::success();
431 return error_code();
432432 }
433433
434434 error_code status(const Twine &Path, file_status &Result) {
454454 Times[1] = Times[0];
455455 if (::futimens(FD, Times))
456456 return error_code(errno, system_category());
457 return error_code::success();
457 return error_code();
458458 #elif defined(HAVE_FUTIMES)
459459 timeval Times[2];
460460 Times[0].tv_sec = Time.toEpochTime();
462462 Times[1] = Times[0];
463463 if (::futimes(FD, Times))
464464 return error_code(errno, system_category());
465 return error_code::success();
465 return error_code();
466466 #else
467467 #warning Missing futimes() and futimens()
468468 return make_error_code(errc::not_supported);
496496 Mapping = ::mmap(nullptr, Size, prot, flags, FD, Offset);
497497 if (Mapping == MAP_FAILED)
498498 return error_code(errno, system_category());
499 return error_code::success();
499 return error_code();
500500 }
501501
502502 mapped_file_region::mapped_file_region(const Twine &path,
601601 ::closedir(reinterpret_cast(it.IterationHandle));
602602 it.IterationHandle = 0;
603603 it.CurrentEntry = directory_entry();
604 return error_code::success();
604 return error_code();
605605 }
606606
607607 error_code detail::directory_iterator_increment(detail::DirIterState &it) {
618618 } else
619619 return directory_iterator_destruct(it);
620620
621 return error_code::success();
621 return error_code();
622622 }
623623
624624 error_code get_magic(const Twine &path, uint32_t len,
649649 }
650650 std::fclose(file);
651651 result.set_size(size);
652 return error_code::success();
652 return error_code();
653653 }
654654
655655 error_code openFileForRead(const Twine &Name, int &ResultFD) {
659659 if (errno != EINTR)
660660 return error_code(errno, system_category());
661661 }
662 return error_code::success();
662 return error_code();
663663 }
664664
665665 error_code openFileForWrite(const Twine &Name, int &ResultFD,
689689 if (errno != EINTR)
690690 return error_code(errno, system_category());
691691 }
692 return error_code::success();
692 return error_code();
693693 }
694694
695695 } // end namespace fs
194194 SpecificBumpPtrAllocator &) {
195195 ArgsOut.append(ArgsIn.begin(), ArgsIn.end());
196196
197 return error_code::success();
197 return error_code();
198198 }
199199
200200 bool Process::StandardInIsUserInput() {
6969 const MemoryBlock *const NearBlock,
7070 unsigned Flags,
7171 error_code &EC) {
72 EC = error_code::success();
72 EC = error_code();
7373 if (NumBytes == 0)
7474 return MemoryBlock();
7575
114114
115115 error_code Memory::releaseMappedMemory(MemoryBlock &M) {
116116 if (M.Address == 0 || M.Size == 0)
117 return error_code::success();
117 return error_code();
118118
119119 if (!VirtualFree(M.Address, 0, MEM_RELEASE))
120120 return error_code(::GetLastError(), system_category());
122122 M.Address = 0;
123123 M.Size = 0;
124124
125 return error_code::success();
125 return error_code();
126126 }
127127
128128 error_code Memory::protectMappedMemory(const MemoryBlock &M,
129129 unsigned Flags) {
130130 if (M.Address == 0 || M.Size == 0)
131 return error_code::success();
131 return error_code();
132132
133133 DWORD Protect = getWindowsProtectionFlags(Flags);
134134
139139 if (Flags & MF_EXEC)
140140 Memory::InvalidateInstructionCache(M.Address, M.Size);
141141
142 return error_code::success();
142 return error_code();
143143 }
144144
145145 /// InvalidateInstructionCache - Before the JIT can run a block of code
158158 error_code EC;
159159 MB = allocateMappedMemory(NumBytes, NearBlock,
160160 MF_READ|MF_WRITE|MF_EXEC, EC);
161 if (EC != error_code::success() && ErrMsg) {
161 if (EC != error_code() && ErrMsg) {
162162 MakeErrMsg(ErrMsg, EC.message());
163163 }
164164 return MB;
166166
167167 bool Memory::ReleaseRWX(MemoryBlock &M, std::string *ErrMsg) {
168168 error_code EC = releaseMappedMemory(M);
169 if (EC == error_code::success())
169 if (EC == error_code())
170170 return false;
171171 MakeErrMsg(ErrMsg, EC.message());
172172 return true;
154154 return ec;
155155 }
156156
157 return error_code::success();
157 return error_code();
158158 }
159159
160160 error_code normalize_separators(SmallVectorImpl &Path) {
161161 (void) Path;
162 return error_code::success();
162 return error_code();
163163 }
164164
165165 // We can't use symbolic links for windows.
179179 if (!::CreateHardLinkW(wide_from.begin(), wide_to.begin(), NULL))
180180 return windows_error(::GetLastError());
181181
182 return error_code::success();
182 return error_code();
183183 }
184184
185185 error_code remove(const Twine &path, bool IgnoreNonExisting) {
190190 if (error_code EC = status(path, ST)) {
191191 if (EC != errc::no_such_file_or_directory || !IgnoreNonExisting)
192192 return EC;
193 return error_code::success();
193 return error_code();
194194 }
195195
196196 if (error_code ec = UTF8ToUTF16(path.toStringRef(path_storage),
203203 if (EC != errc::no_such_file_or_directory || !IgnoreNonExisting)
204204 return EC;
205205 }
206 return error_code::success();
206 return error_code();
207207 }
208208 if (!::DeleteFileW(c_str(path_utf16))) {
209209 error_code EC = windows_error(::GetLastError());
210210 if (EC != errc::no_such_file_or_directory || !IgnoreNonExisting)
211211 return EC;
212212 }
213 return error_code::success();
213 return error_code();
214214 }
215215
216216 error_code rename(const Twine &from, const Twine &to) {
226226 if (error_code ec = UTF8ToUTF16(f, wide_from)) return ec;
227227 if (error_code ec = UTF8ToUTF16(t, wide_to)) return ec;
228228
229 error_code ec = error_code::success();
229 error_code ec = error_code();
230230 for (int i = 0; i < 2000; i++) {
231231 if (::MoveFileExW(wide_from.begin(), wide_to.begin(),
232232 MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING))
233 return error_code::success();
233 return error_code();
234234 ec = windows_error(::GetLastError());
235235 if (ec != windows_error::access_denied)
236236 break;
282282 result = false;
283283 } else
284284 result = true;
285 return error_code::success();
285 return error_code();
286286 }
287287
288288 bool can_write(const Twine &Path) {
324324 if (error_code ec = status(A, fsA)) return ec;
325325 if (error_code ec = status(B, fsB)) return ec;
326326 result = equivalent(fsA, fsB);
327 return error_code::success();
327 return error_code();
328328 }
329329
330330 static bool isReservedName(StringRef path) {
362362 if (Err != NO_ERROR)
363363 return windows_error(Err);
364364 Result = file_status(file_type::type_unknown);
365 return error_code::success();
365 return error_code();
366366 }
367367 case FILE_TYPE_DISK:
368368 break;
369369 case FILE_TYPE_CHAR:
370370 Result = file_status(file_type::character_file);
371 return error_code::success();
371 return error_code();
372372 case FILE_TYPE_PIPE:
373373 Result = file_status(file_type::fifo_file);
374 return error_code::success();
374 return error_code();
375375 }
376376
377377 BY_HANDLE_FILE_INFORMATION Info;
387387 Info.ftLastWriteTime.dwLowDateTime,
388388 Info.dwVolumeSerialNumber, Info.nFileSizeHigh,
389389 Info.nFileSizeLow, Info.nFileIndexHigh, Info.nFileIndexLow);
390 return error_code::success();
390 return error_code();
391391 }
392392
393393 handle_status_error:
409409 StringRef path8 = path.toStringRef(path_storage);
410410 if (isReservedName(path8)) {
411411 result = file_status(file_type::character_file);
412 return error_code::success();
412 return error_code();
413413 }
414414
415415 if (error_code ec = UTF8ToUTF16(path8, path_utf16))
457457 HANDLE FileHandle = reinterpret_cast(_get_osfhandle(FD));
458458 if (!SetFileTime(FileHandle, NULL, &FT, &FT))
459459 return windows_error(::GetLastError());
460 return error_code::success();
460 return error_code();
461461 }
462462
463463 error_code get_magic(const Twine &path, uint32_t len,
499499 }
500500
501501 result.set_size(len);
502 return error_code::success();
502 return error_code();
503503 }
504504
505505 error_code mapped_file_region::init(int FD, bool CloseFD, uint64_t Offset) {
583583 _close(FileDescriptor); // Also closes FileHandle.
584584 } else
585585 ::CloseHandle(FileHandle);
586 return error_code::success();
586 return error_code();
587587 }
588588
589589 mapped_file_region::mapped_file_region(const Twine &path,
752752 path::append(directory_entry_path, directory_entry_name_utf8.str());
753753 it.CurrentEntry = directory_entry(directory_entry_path.str());
754754
755 return error_code::success();
755 return error_code();
756756 }
757757
758758 error_code detail::directory_iterator_destruct(detail::DirIterState &it) {
761761 ScopedFindHandle close(HANDLE(it.IterationHandle));
762762 it.IterationHandle = 0;
763763 it.CurrentEntry = directory_entry();
764 return error_code::success();
764 return error_code();
765765 }
766766
767767 error_code detail::directory_iterator_increment(detail::DirIterState &it) {
787787 return ec;
788788
789789 it.CurrentEntry.replace_filename(Twine(directory_entry_path_utf8));
790 return error_code::success();
790 return error_code();
791791 }
792792
793793 error_code openFileForRead(const Twine &Name, int &ResultFD) {
820820 }
821821
822822 ResultFD = FD;
823 return error_code::success();
823 return error_code();
824824 }
825825
826826 error_code openFileForWrite(const Twine &Name, int &ResultFD,
878878 }
879879
880880 ResultFD = FD;
881 return error_code::success();
881 return error_code();
882882 }
883883 } // end namespace fs
884884
922922 utf16.push_back(0);
923923 utf16.pop_back();
924924
925 return llvm::error_code::success();
925 return llvm::error_code();
926926 }
927927
928928 llvm::error_code UTF16ToUTF8(const wchar_t *utf16, size_t utf16_len,
950950 utf8.push_back(0);
951951 utf8.pop_back();
952952
953 return llvm::error_code::success();
953 return llvm::error_code();
954954 }
955955 } // end namespace windows
956956 } // end namespace sys
207207 if (ec)
208208 return ec;
209209
210 return error_code::success();
210 return error_code();
211211 }
212212
213213 bool Process::StandardInIsUserInput() {
5858 TEST_P(MappedMemoryTest, AllocAndRelease) {
5959 error_code EC;
6060 MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
61 EXPECT_EQ(error_code::success(), EC);
61 EXPECT_EQ(error_code(), EC);
6262
6363 EXPECT_NE((void*)0, M1.base());
6464 EXPECT_LE(sizeof(int), M1.size());
6969 TEST_P(MappedMemoryTest, MultipleAllocAndRelease) {
7070 error_code EC;
7171 MemoryBlock M1 = Memory::allocateMappedMemory(16, 0, Flags, EC);
72 EXPECT_EQ(error_code::success(), EC);
72 EXPECT_EQ(error_code(), EC);
7373 MemoryBlock M2 = Memory::allocateMappedMemory(64, 0, Flags, EC);
74 EXPECT_EQ(error_code::success(), EC);
74 EXPECT_EQ(error_code(), EC);
7575 MemoryBlock M3 = Memory::allocateMappedMemory(32, 0, Flags, EC);
76 EXPECT_EQ(error_code::success(), EC);
76 EXPECT_EQ(error_code(), EC);
7777
7878 EXPECT_NE((void*)0, M1.base());
7979 EXPECT_LE(16U, M1.size());
8989 EXPECT_FALSE(Memory::releaseMappedMemory(M1));
9090 EXPECT_FALSE(Memory::releaseMappedMemory(M3));
9191 MemoryBlock M4 = Memory::allocateMappedMemory(16, 0, Flags, EC);
92 EXPECT_EQ(error_code::success(), EC);
92 EXPECT_EQ(error_code(), EC);
9393 EXPECT_NE((void*)0, M4.base());
9494 EXPECT_LE(16U, M4.size());
9595 EXPECT_FALSE(Memory::releaseMappedMemory(M4));
104104
105105 error_code EC;
106106 MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
107 EXPECT_EQ(error_code::success(), EC);
107 EXPECT_EQ(error_code(), EC);
108108
109109 EXPECT_NE((void*)0, M1.base());
110110 EXPECT_LE(sizeof(int), M1.size());
123123 return;
124124 error_code EC;
125125 MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
126 EXPECT_EQ(error_code::success(), EC);
126 EXPECT_EQ(error_code(), EC);
127127 MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), 0, Flags, EC);
128 EXPECT_EQ(error_code::success(), EC);
128 EXPECT_EQ(error_code(), EC);
129129 MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), 0, Flags, EC);
130 EXPECT_EQ(error_code::success(), EC);
130 EXPECT_EQ(error_code(), EC);
131131
132132 EXPECT_FALSE(doesOverlap(M1, M2));
133133 EXPECT_FALSE(doesOverlap(M2, M3));
159159 EXPECT_FALSE(Memory::releaseMappedMemory(M3));
160160
161161 MemoryBlock M4 = Memory::allocateMappedMemory(64 * sizeof(int), 0, Flags, EC);
162 EXPECT_EQ(error_code::success(), EC);
162 EXPECT_EQ(error_code(), EC);
163163 EXPECT_NE((void*)0, M4.base());
164164 EXPECT_LE(64U * sizeof(int), M4.size());
165165 x = (int*)M4.base();
177177 TEST_P(MappedMemoryTest, EnabledWrite) {
178178 error_code EC;
179179 MemoryBlock M1 = Memory::allocateMappedMemory(2 * sizeof(int), 0, Flags, EC);
180 EXPECT_EQ(error_code::success(), EC);
180 EXPECT_EQ(error_code(), EC);
181181 MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), 0, Flags, EC);
182 EXPECT_EQ(error_code::success(), EC);
182 EXPECT_EQ(error_code(), EC);
183183 MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), 0, Flags, EC);
184 EXPECT_EQ(error_code::success(), EC);
184 EXPECT_EQ(error_code(), EC);
185185
186186 EXPECT_NE((void*)0, M1.base());
187187 EXPECT_LE(2U * sizeof(int), M1.size());
216216 EXPECT_EQ(6, y[6]);
217217
218218 MemoryBlock M4 = Memory::allocateMappedMemory(16, 0, Flags, EC);
219 EXPECT_EQ(error_code::success(), EC);
219 EXPECT_EQ(error_code(), EC);
220220 EXPECT_NE((void*)0, M4.base());
221221 EXPECT_LE(16U, M4.size());
222 EXPECT_EQ(error_code::success(), Memory::protectMappedMemory(M4, getTestableEquivalent(Flags)));
222 EXPECT_EQ(error_code(), Memory::protectMappedMemory(M4, getTestableEquivalent(Flags)));
223223 x = (int*)M4.base();
224224 *x = 4;
225225 EXPECT_EQ(4, *x);
230230 TEST_P(MappedMemoryTest, SuccessiveNear) {
231231 error_code EC;
232232 MemoryBlock M1 = Memory::allocateMappedMemory(16, 0, Flags, EC);
233 EXPECT_EQ(error_code::success(), EC);
233 EXPECT_EQ(error_code(), EC);
234234 MemoryBlock M2 = Memory::allocateMappedMemory(64, &M1, Flags, EC);
235 EXPECT_EQ(error_code::success(), EC);
235 EXPECT_EQ(error_code(), EC);
236236 MemoryBlock M3 = Memory::allocateMappedMemory(32, &M2, Flags, EC);
237 EXPECT_EQ(error_code::success(), EC);
237 EXPECT_EQ(error_code(), EC);
238238
239239 EXPECT_NE((void*)0, M1.base());
240240 EXPECT_LE(16U, M1.size());
256256 error_code EC;
257257 MemoryBlock Near((void*)(3*PageSize), 16);
258258 MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC);
259 EXPECT_EQ(error_code::success(), EC);
259 EXPECT_EQ(error_code(), EC);
260260 MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC);
261 EXPECT_EQ(error_code::success(), EC);
261 EXPECT_EQ(error_code(), EC);
262262 MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
263 EXPECT_EQ(error_code::success(), EC);
263 EXPECT_EQ(error_code(), EC);
264264
265265 EXPECT_NE((void*)0, M1.base());
266266 EXPECT_LE(16U, M1.size());
278278 error_code EC;
279279 MemoryBlock Near(0, 0);
280280 MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC);
281 EXPECT_EQ(error_code::success(), EC);
281 EXPECT_EQ(error_code(), EC);
282282 MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC);
283 EXPECT_EQ(error_code::success(), EC);
283 EXPECT_EQ(error_code(), EC);
284284 MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
285 EXPECT_EQ(error_code::success(), EC);
285 EXPECT_EQ(error_code(), EC);
286286
287287 EXPECT_NE((void*)0, M1.base());
288288 EXPECT_LE(16U, M1.size());
304304 error_code EC;
305305 MemoryBlock Near((void*)(4*PageSize), 0);
306306 MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC);
307 EXPECT_EQ(error_code::success(), EC);
307 EXPECT_EQ(error_code(), EC);
308308 MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC);
309 EXPECT_EQ(error_code::success(), EC);
309 EXPECT_EQ(error_code(), EC);
310310 MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
311 EXPECT_EQ(error_code::success(), EC);
311 EXPECT_EQ(error_code(), EC);
312312
313313 EXPECT_NE((void*)0, M1.base());
314314 EXPECT_LE(16U, M1.size());
330330 error_code EC;
331331 MemoryBlock Near((void*)(2*PageSize+5), 0);
332332 MemoryBlock M1 = Memory::allocateMappedMemory(15, &Near, Flags, EC);
333 EXPECT_EQ(error_code::success(), EC);
333 EXPECT_EQ(error_code(), EC);
334334
335335 EXPECT_NE((void*)0, M1.base());
336336 EXPECT_LE(sizeof(int), M1.size());