diff options
author | David Blaikie <dblaikie@gmail.com> | 2012-02-09 19:24:12 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2012-02-09 19:24:12 +0000 |
commit | 58604cd944eec4a75046076cb53eb708aaf2ee09 (patch) | |
tree | a739bf5bdf6be6dfb032bba9eea7cb2baa98eac7 /lib/Support/PathV2.cpp | |
parent | e7c2c15b0cfa14d6b273e0e95d9de133cc958da8 (diff) |
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
Diffstat (limited to 'lib/Support/PathV2.cpp')
-rw-r--r-- | lib/Support/PathV2.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/Support/PathV2.cpp b/lib/Support/PathV2.cpp index f0ce331c78..3ef13e253f 100644 --- a/lib/Support/PathV2.cpp +++ b/lib/Support/PathV2.cpp @@ -31,8 +31,6 @@ namespace { const char prefered_separator = '/'; #endif - const llvm::error_code success; - StringRef find_first_component(StringRef path) { // Look for this first component in the following order. // * empty (in this case we return an empty string) @@ -607,7 +605,7 @@ error_code make_absolute(SmallVectorImpl<char> &path) { // Already absolute. if (rootName && rootDirectory) - return success; + return error_code::success(); // All of the following conditions will need the current directory. SmallString<128> current_dir; @@ -619,7 +617,7 @@ error_code make_absolute(SmallVectorImpl<char> &path) { path::append(current_dir, p); // Set path to the result. path.swap(current_dir); - return success; + return error_code::success(); } if (!rootName && rootDirectory) { @@ -628,7 +626,7 @@ error_code make_absolute(SmallVectorImpl<char> &path) { path::append(curDirRootName, p); // Set path to the result. path.swap(curDirRootName); - return success; + return error_code::success(); } if (rootName && !rootDirectory) { @@ -640,7 +638,7 @@ error_code make_absolute(SmallVectorImpl<char> &path) { SmallString<128> res; path::append(res, pRootName, bRootDirectory, bRelativePath, pRelativePath); path.swap(res); - return success; + return error_code::success(); } llvm_unreachable("All rootName and rootDirectory combinations should have " @@ -679,7 +677,7 @@ error_code is_directory(const Twine &path, bool &result) { if (error_code ec = status(path, st)) return ec; result = is_directory(st); - return success; + return error_code::success(); } bool is_regular_file(file_status status) { @@ -691,7 +689,7 @@ error_code is_regular_file(const Twine &path, bool &result) { if (error_code ec = status(path, st)) return ec; result = is_regular_file(st); - return success; + return error_code::success(); } bool is_symlink(file_status status) { @@ -703,7 +701,7 @@ error_code is_symlink(const Twine &path, bool &result) { if (error_code ec = status(path, st)) return ec; result = is_symlink(st); - return success; + return error_code::success(); } bool is_other(file_status status) { @@ -730,13 +728,13 @@ error_code has_magic(const Twine &path, const Twine &magic, bool &result) { if (ec == errc::value_too_large) { // Magic.size() > file_size(Path). result = false; - return success; + return error_code::success(); } return ec; } result = Magic == Buffer; - return success; + return error_code::success(); } /// @brief Identify the magic in magic. @@ -857,7 +855,7 @@ error_code identify_magic(const Twine &path, file_magic &result) { return ec; result = identify_magic(Magic); - return success; + return error_code::success(); } namespace { @@ -884,7 +882,7 @@ error_code remove_all_r(StringRef path, file_type ft, uint32_t &count) { ++count; } - return success; + return error_code::success(); } } // end unnamed namespace |