Change default error_code ctor to a 'named ctor' so it's more self-documenting.
Unify default construction of error_code uses on this idiom so that users don't
feel compelled to make static globals for naming convenience. (unfortunately I
couldn't make the original ctor private as some APIs don't return their result,
instead using an out parameter (that makes sense to default construct) - which
is a bit of a pity. I did, however, find/fix some cases of unnecessary default
construction of error_code before I hit the unfixable cases)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150197 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Support/Windows/PathV2.inc b/lib/Support/Windows/PathV2.inc
index 7ca33c0..e9ce5d9 100644
--- a/lib/Support/Windows/PathV2.inc
+++ b/lib/Support/Windows/PathV2.inc
@@ -62,7 +62,7 @@
utf16.push_back(0);
utf16.pop_back();
- return success;
+ return error_code::success();
}
error_code UTF16ToUTF8(const wchar_t *utf16, size_t utf16_len,
@@ -92,7 +92,7 @@
utf8.push_back(0);
utf8.pop_back();
- return success;
+ return error_code::success();
}
error_code TempDir(SmallVectorImpl<wchar_t> &result) {
@@ -108,7 +108,7 @@
}
result.set_size(len);
- return success;
+ return error_code::success();
}
bool is_separator(const wchar_t value) {
@@ -167,7 +167,7 @@
if (len == 0)
return windows_error(::GetLastError());
- return success;
+ return error_code::success();
}
error_code copy_file(const Twine &from, const Twine &to, copy_option copt) {
@@ -190,7 +190,7 @@
if (res == 0)
return windows_error(::GetLastError());
- return success;
+ return error_code::success();
}
error_code create_directory(const Twine &path, bool &existed) {
@@ -210,7 +210,7 @@
} else
existed = false;
- return success;
+ return error_code::success();
}
error_code create_hard_link(const Twine &to, const Twine &from) {
@@ -229,7 +229,7 @@
if (!::CreateHardLinkW(wide_from.begin(), wide_to.begin(), NULL))
return windows_error(::GetLastError());
- return success;
+ return error_code::success();
}
error_code create_symlink(const Twine &to, const Twine &from) {
@@ -252,7 +252,7 @@
if (!create_symbolic_link_api(wide_from.begin(), wide_to.begin(), 0))
return windows_error(::GetLastError());
- return success;
+ return error_code::success();
}
error_code remove(const Twine &path, bool &existed) {
@@ -285,7 +285,7 @@
existed = true;
}
- return success;
+ return error_code::success();
}
error_code rename(const Twine &from, const Twine &to) {
@@ -305,7 +305,7 @@
MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING))
return windows_error(::GetLastError());
- return success;
+ return error_code::success();
}
error_code resize_file(const Twine &path, uint64_t size) {
@@ -347,7 +347,7 @@
result = false;
} else
result = true;
- return success;
+ return error_code::success();
}
bool equivalent(file_status A, file_status B) {
@@ -366,7 +366,7 @@
if (error_code ec = status(A, fsA)) return ec;
if (error_code ec = status(B, fsB)) return ec;
result = equivalent(fsA, fsB);
- return success;
+ return error_code::success();
}
error_code file_size(const Twine &path, uint64_t &result) {
@@ -387,7 +387,7 @@
(uint64_t(FileData.nFileSizeHigh) << (sizeof(FileData.nFileSizeLow) * 8))
+ FileData.nFileSizeLow;
- return success;
+ return error_code::success();
}
static bool isReservedName(StringRef path) {
@@ -420,7 +420,7 @@
StringRef path8 = path.toStringRef(path_storage);
if (isReservedName(path8)) {
result = file_status(file_type::character_file);
- return success;
+ return error_code::success();
}
if (error_code ec = UTF8ToUTF16(path8, path_utf16))
@@ -470,7 +470,7 @@
result.VolumeSerialNumber = Info.dwVolumeSerialNumber;
}
- return success;
+ return error_code::success();
handle_status_error:
error_code ec = windows_error(::GetLastError());
@@ -484,7 +484,7 @@
return ec;
}
- return success;
+ return error_code::success();
}
error_code unique_file(const Twine &model, int &result_fd,
@@ -611,7 +611,7 @@
}
result_fd = fd;
- return success;
+ return error_code::success();
}
error_code get_magic(const Twine &path, uint32_t len,
@@ -653,7 +653,7 @@
}
result.set_size(len);
- return success;
+ return error_code::success();
}
error_code detail::directory_iterator_construct(detail::DirIterState &it,
@@ -705,7 +705,7 @@
path::append(directory_entry_path, directory_entry_name_utf8.str());
it.CurrentEntry = directory_entry(directory_entry_path.str());
- return success;
+ return error_code::success();
}
error_code detail::directory_iterator_destruct(detail::DirIterState &it) {
@@ -714,7 +714,7 @@
ScopedFindHandle close(HANDLE(it.IterationHandle));
it.IterationHandle = 0;
it.CurrentEntry = directory_entry();
- return success;
+ return error_code::success();
}
error_code detail::directory_iterator_increment(detail::DirIterState &it) {
@@ -740,7 +740,7 @@
return ec;
it.CurrentEntry.replace_filename(Twine(directory_entry_path_utf8));
- return success;
+ return error_code::success();
}
} // end namespace fs