-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Support][FileSystem] Prefer status
with file_t
parameter. NFC.
#157581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[Support][FileSystem] Prefer status
with file_t
parameter. NFC.
#157581
Conversation
Created using spr 1.3.6
@llvm/pr-subscribers-llvm-support Author: Steven Wu (cachemeifyoucan) ChangesWhen searching the documentation for LLVM for In reality, file handle version is more portable and should be displayed Full diff: https://github.com/llvm/llvm-project/pull/157581.diff 1 Files Affected:
diff --git a/llvm/include/llvm/Support/FileSystem.h b/llvm/include/llvm/Support/FileSystem.h
index a21b0a272d2b0..88299cab7d7ee 100644
--- a/llvm/include/llvm/Support/FileSystem.h
+++ b/llvm/include/llvm/Support/FileSystem.h
@@ -640,12 +640,12 @@ LLVM_ABI std::error_code is_other(const Twine &path, bool &result);
LLVM_ABI std::error_code status(const Twine &path, file_status &result,
bool follow = true);
-/// A version for when a file descriptor is already available.
-LLVM_ABI std::error_code status(int FD, file_status &Result);
+/// A version for when a file handle is already available.
+LLVM_ABI std::error_code status(file_t FD, file_status &Result);
#ifdef _WIN32
/// A version for when a file descriptor is already available.
-LLVM_ABI std::error_code status(file_t FD, file_status &Result);
+LLVM_ABI std::error_code status(int FD, file_status &Result);
#endif
/// Get file creation mode mask of the process.
|
Possible followup:
This makes no need to call |
Created using spr 1.3.6
Preferring the handle version of the API is reasonable, but if this is purely for documentation purposes, I think that we should change the guard instead of changing which variant is under the guard. |
It is actually only windows has the explicit file descriptor version. Everywhere else is file handle version because it is just the same type (I hope that won't introduce ambiguity in the code). |
Oh, that is a rather annoying ambiguity. |
The other reason for the change is if we can find a way to seamlessly switching to |
Related, write an RFC here: https://discourse.llvm.org/t/rfc-unified-llvm-fs-apis-to-use-sys-file-t-instead-of-int-file-descriptor/88240 |
When searching the documentation for LLVM for
llvm::sys::fs::status
,only the version with file descriptor can be found because the
documentation is built on the UNIX host and the file handle version is
defined out.
In reality, file handle version is more portable and should be displayed
instead. On UNIX, these two functions have the same underlying type,
thus it shouldn't matter which one is declared, and both versions are
still available on Windows for compatibility.