[libc-commits] [PATCH] D155766: [libc] Remove global constructor in `getopt` implementation
Alex Brachet via Phabricator via libc-commits
libc-commits at lists.llvm.org
Thu Jul 20 03:46:37 PDT 2023
abrachet added a comment.
It's not clear what's different about the `impl::` objects and the `__llvm_libc::stderr` one. [1] If this changes anything it just changes the decision the compiler decided to make, but it is still allowed to use a constructor here. I think to properly remove a global constructor the better route is what we did for atexit <https://github.com/llvm/llvm-project/blob/2c38740ca661a10866a796db105752e15372ddce/libc/src/stdlib/atexit.cpp#L45> and the cmake <https://github.com/llvm/llvm-project/blob/2c38740ca661a10866a796db105752e15372ddce/libc/src/stdlib/CMakeLists.txt#L363-L364> that goes with it.
The `opterr` change looks good.
[1] In fact, if there is a difference it would be that `__llvm_libc::stderr` is (should be if not) a hidden alias to a default visibility `stderr`, which would make this a relative relocation, while the `impl::` objects are symbolic relocations.
================
Comment at: libc/src/unistd/getopt.cpp:25
template <typename T> struct RefWrapper {
- RefWrapper(T *ptr) : ptr(ptr) {}
+ constexpr RefWrapper(T *ptr) : ptr(ptr) {}
RefWrapper &operator=(const RefWrapper &) = default;
----------------
This explicit constructor can just be removed instead, I think.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155766/new/
https://reviews.llvm.org/D155766
More information about the libc-commits
mailing list