Skip to content

[libc++] Properly guard std::filesystem with >= C++17 #72701

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

Merged
merged 3 commits into from
Nov 28, 2023

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Nov 17, 2023

is a C++17 addition. In C++11 and C++14 modes, we actually have all the code for but it is hidden behind a non-inline namespace __fs so it is not accessible. Instead of doing this unusual dance, just guard the code for filesystem behind a classic C++17 check like we normally do.

@ldionne ldionne requested a review from a team as a code owner November 17, 2023 21:11
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Nov 17, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 17, 2023

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

<filesystem> is a C++17 addition. In C++11 and C++14 modes, we actually have all the code for <filesystem> but it is hidden behind a non-inline namespace __fs so it is not accessible. Instead of doing this unusual dance, just guard the code for filesystem behind a classic C++17 check like we normally do.


Patch is 170.54 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/72701.diff

170 Files Affected:

  • (modified) libcxx/benchmarks/filesystem.bench.cpp (+4-1)
  • (modified) libcxx/include/__chrono/file_clock.h (+1-1)
  • (modified) libcxx/include/__config (+2-9)
  • (modified) libcxx/include/__filesystem/copy_options.h (+2-2)
  • (modified) libcxx/include/__filesystem/directory_entry.h (+16-16)
  • (modified) libcxx/include/__filesystem/directory_iterator.h (+4-4)
  • (modified) libcxx/include/__filesystem/directory_options.h (+2-2)
  • (modified) libcxx/include/__filesystem/file_status.h (+2-2)
  • (modified) libcxx/include/__filesystem/file_time_type.h (+2-2)
  • (modified) libcxx/include/__filesystem/file_type.h (+2-2)
  • (modified) libcxx/include/__filesystem/filesystem_error.h (+2-2)
  • (modified) libcxx/include/__filesystem/operations.h (+2-2)
  • (modified) libcxx/include/__filesystem/path.h (+7-7)
  • (modified) libcxx/include/__filesystem/path_iterator.h (+2-2)
  • (modified) libcxx/include/__filesystem/perm_options.h (+2-2)
  • (modified) libcxx/include/__filesystem/perms.h (+2-2)
  • (modified) libcxx/include/__filesystem/recursive_directory_iterator.h (+4-4)
  • (modified) libcxx/include/__filesystem/space_info.h (+2-2)
  • (modified) libcxx/include/__filesystem/u8path.h (+2-2)
  • (modified) libcxx/include/fstream (+1-1)
  • (modified) libcxx/src/filesystem/directory_entry.cpp (+3-3)
  • (modified) libcxx/src/filesystem/file_descriptor.h (+1-1)
  • (modified) libcxx/test/libcxx/input.output/filesystems/class.directory_entry/directory_entry.mods/last_write_time.pass.cpp (+2-1)
  • (modified) libcxx/test/libcxx/input.output/filesystems/class.path/path.itr/assert.iterator.pass.cpp (+2-1)
  • (modified) libcxx/test/libcxx/input.output/filesystems/class.path/path.member/path.native.obs/string_alloc.pass.cpp (+3-3)
  • (modified) libcxx/test/libcxx/input.output/filesystems/class.path/path.req/is_pathable.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/copy.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/copy_assign.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/default.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/default_const.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/move.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/move_assign.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.io/directory_entry.io.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/refresh.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/replace_filename.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/comparisons.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/path.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/status.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/symlink_status.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/copy.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/copy_assign.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/default_ctor.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/equal.pass.cpp (+2-1)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/increment.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/move.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/move_assign.pass.cpp (+4-4)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.nonmembers/begin_end.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_iterator/iterator_concept_conformance.compile.pass.cpp (+2-1)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_iterator/range_concept_conformance.compile.pass.cpp (+2-1)
  • (modified) libcxx/test/std/input.output/filesystems/class.directory_iterator/types.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.file_status/file_status.cons.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.file_status/file_status.mods.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.file_status/file_status.obs.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.file_status/file_status.status.eq.ops.cpp (+1-1)
  • (modified) libcxx/test/std/input.output/filesystems/class.filesystem_error/filesystem_error.members.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.itr/iterator.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.append.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.assign/copy.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.assign/move.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.assign/source.pass.cpp (+3-4)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.charconv.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.compare.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.concat.pass.cpp (+3-4)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.construct/copy.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.construct/default.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.construct/move.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.construct/source.pass.cpp (+3-4)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.decompose/empty.verify.cpp (+2-1)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.decompose/path.decompose.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_normal.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_relative_and_proximate.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.generic.obs/generic_string_alloc.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.generic.obs/named_overloads.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.hash_enabled.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/clear.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/make_preferred.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/remove_filename.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/replace_extension.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/replace_filename.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/swap.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.native.obs/c_str.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.native.obs/named_overloads.pass.cpp (+3-4)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.native.obs/native.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.native.obs/operator_string.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.member/path.query/tested_in_path_decompose.pass.cpp (+1-1)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.nonmember/append_op.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.nonmember/append_op.verify.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.nonmember/comparison_ops.verify.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.nonmember/comparison_ops_tested_elsewhere.pass.cpp (+1-1)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.nonmember/path.factory.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.nonmember/path.io.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.nonmember/path.io.unicode_bug.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path.nonmember/swap.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/path_helper.h (+2-1)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/range_concept_conformance.compile.pass.cpp (+2-2)
  • (modified) libcxx/test/std/input.output/filesystems/class.path/synop.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.rec.dir.itr/range_concept_conformance.compile.pass.cpp (+2-1)
  • (modified) libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy_assign.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp (+3-4)
  • (modified) libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/depth.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/disable_recursion_pending.pass.cpp (+3-4)
  • (modified) libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/equal.pass.cpp (+2-1)
  • (modified) libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/move.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/move_assign.pass.cpp (+4-4)
  • (modified) libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/pop.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.nonmembers/begin_end.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.enum/enum.copy_options.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.enum/enum.directory_options.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.enum/enum.file_type.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.enum/enum.path.format.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/fs.enum/enum.perm_options.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.enum/enum.perms.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.filesystem.synopsis/file_time_type.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/fs.filesystem.synopsis/file_time_type_resolution.compile.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.filesystem.synopsis/space_info.pass.cpp (+2-2)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.absolute/absolute.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.canonical/canonical.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file_large.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_symlink/copy_symlink.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directory/create_directory_with_attributes.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directory_symlink/create_directory_symlink.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_hard_link/create_hard_link.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_symlink/create_symlink.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.current_path/current_path.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.equivalent/equivalent.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.exists/exists.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.file_size/file_size.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_block_file/is_block_file.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_char_file/is_character_file.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_directory/is_directory.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_fifo/is_fifo.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_other/is_other.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_regular_file/is_regular_file.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_socket/is_socket.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_symlink/is_symlink.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.permissions/permissions.pass.cpp (+3-5)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.proximate/proximate.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.read_symlink/read_symlink.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.relative/relative.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.remove/remove.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.remove_all/remove_all.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.remove_all/toctou.pass.cpp (+3-2)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.rename/rename.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.resize_file/resize_file.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.space/space.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.status/status.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.status_known/status_known.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.symlink_status/symlink_status.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp (+3-3)
  • (modified) libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp (+3-2)
  • (removed) libcxx/test/std/input.output/filesystems/fs.req.namespace/namespace.verify.cpp (-18)
  • (removed) libcxx/test/support/filesystem_include.h (-13)
  • (modified) libcxx/test/support/filesystem_test_helper.h (+2-1)
diff --git a/libcxx/benchmarks/filesystem.bench.cpp b/libcxx/benchmarks/filesystem.bench.cpp
index 44200fb3cab08bd..d1a1763a7e463cd 100644
--- a/libcxx/benchmarks/filesystem.bench.cpp
+++ b/libcxx/benchmarks/filesystem.bench.cpp
@@ -1,8 +1,11 @@
+#include <filesystem>
+
 #include "GenerateInput.h"
 #include "benchmark/benchmark.h"
-#include "filesystem_include.h"
 #include "test_iterators.h"
 
+namespace fs = std::filesystem;
+
 static const size_t TestNumInputs = 1024;
 
 template <class GenInputs>
diff --git a/libcxx/include/__chrono/file_clock.h b/libcxx/include/__chrono/file_clock.h
index 557a880ed452272..9ea2fcb979355c1 100644
--- a/libcxx/include/__chrono/file_clock.h
+++ b/libcxx/include/__chrono/file_clock.h
@@ -35,7 +35,7 @@ namespace chrono
 {
 
 // [time.clock.file], type file_clock
-using file_clock = _VSTD_FS::_FilesystemClock;
+using file_clock = filesystem::_FilesystemClock;
 
 template<class _Duration>
 using file_time = time_point<file_clock, _Duration>;
diff --git a/libcxx/include/__config b/libcxx/include/__config
index e8da358bb8d7cd5..defe8f5129faa66 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -838,19 +838,12 @@ typedef __char32_t char32_t;
 
 _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
 
-#  if _LIBCPP_STD_VER >= 17
-#    define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM                                                                         \
-       _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
-#  else
-#    define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM                                                                         \
-      _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
-#  endif
+#  define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD                                               \
+                                             inline namespace __fs { namespace filesystem {
 
 #  define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }}
 // clang-format on
 
-#  define _VSTD_FS std::__fs::filesystem
-
 #  if __has_attribute(__enable_if__)
 #    define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, "")))
 #  endif
diff --git a/libcxx/include/__filesystem/copy_options.h b/libcxx/include/__filesystem/copy_options.h
index bc99d55d490bd2f..c8c96cef721bc9f 100644
--- a/libcxx/include/__filesystem/copy_options.h
+++ b/libcxx/include/__filesystem/copy_options.h
@@ -17,7 +17,7 @@
 #  pragma GCC system_header
 #endif
 
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER >= 17
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
@@ -75,6 +75,6 @@ inline copy_options& operator^=(copy_options& __lhs, copy_options __rhs) {
 
 _LIBCPP_END_NAMESPACE_FILESYSTEM
 
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_STD_VER >= 17
 
 #endif // _LIBCPP___FILESYSTEM_COPY_OPTIONS_H
diff --git a/libcxx/include/__filesystem/directory_entry.h b/libcxx/include/__filesystem/directory_entry.h
index 6baaca0709edb5c..c538f62a5e77644 100644
--- a/libcxx/include/__filesystem/directory_entry.h
+++ b/libcxx/include/__filesystem/directory_entry.h
@@ -34,14 +34,14 @@
 _LIBCPP_PUSH_MACROS
 #include <__undef_macros>
 
-#if !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH
 
 class directory_entry {
-  typedef _VSTD_FS::path _Path;
+  typedef path _Path;
 
 public:
   // constructors and destructors
@@ -104,11 +104,11 @@ class directory_entry {
   operator const _Path&() const noexcept { return __p_; }
 
   _LIBCPP_INLINE_VISIBILITY
-  bool exists() const { return _VSTD_FS::exists(file_status{__get_ft()}); }
+  bool exists() const { return filesystem::exists(file_status{__get_ft()}); }
 
   _LIBCPP_INLINE_VISIBILITY
   bool exists(error_code& __ec) const noexcept {
-    return _VSTD_FS::exists(file_status{__get_ft(&__ec)});
+    return filesystem::exists(file_status{__get_ft(&__ec)});
   }
 
   _LIBCPP_INLINE_VISIBILITY
@@ -144,11 +144,11 @@ class directory_entry {
   }
 
   _LIBCPP_INLINE_VISIBILITY
-  bool is_other() const { return _VSTD_FS::is_other(file_status{__get_ft()}); }
+  bool is_other() const { return filesystem::is_other(file_status{__get_ft()}); }
 
   _LIBCPP_INLINE_VISIBILITY
   bool is_other(error_code& __ec) const noexcept {
-    return _VSTD_FS::is_other(file_status{__get_ft(&__ec)});
+    return filesystem::is_other(file_status{__get_ft(&__ec)});
   }
 
   _LIBCPP_INLINE_VISIBILITY
@@ -366,7 +366,7 @@ class directory_entry {
     case _IterNonSymlink:
     case _RefreshNonSymlink:
       file_status __st(__data_.__type_);
-      if (__ec && !_VSTD_FS::exists(__st))
+      if (__ec && !filesystem::exists(__st))
         *__ec = make_error_code(errc::no_such_file_or_directory);
       else if (__ec)
         __ec->clear();
@@ -386,7 +386,7 @@ class directory_entry {
     case _RefreshNonSymlink:
     case _RefreshSymlink: {
       file_status __st(__data_.__type_);
-      if (__ec && !_VSTD_FS::exists(__st))
+      if (__ec && !filesystem::exists(__st))
         *__ec = make_error_code(errc::no_such_file_or_directory);
       else if (__ec)
         __ec->clear();
@@ -434,15 +434,15 @@ class directory_entry {
     case _IterNonSymlink:
     case _IterSymlink:
     case _RefreshSymlinkUnresolved:
-      return _VSTD_FS::__file_size(__p_, __ec);
+      return filesystem::__file_size(__p_, __ec);
     case _RefreshSymlink:
     case _RefreshNonSymlink: {
       error_code __m_ec;
       file_status __st(__get_ft(&__m_ec));
       __handle_error("in directory_entry::file_size", __ec, __m_ec);
-      if (_VSTD_FS::exists(__st) && !_VSTD_FS::is_regular_file(__st)) {
-        errc __err_kind = _VSTD_FS::is_directory(__st) ? errc::is_a_directory
-                                                       : errc::not_supported;
+      if (filesystem::exists(__st) && !filesystem::is_regular_file(__st)) {
+        errc __err_kind = filesystem::is_directory(__st) ? errc::is_a_directory
+                                                         : errc::not_supported;
         __handle_error("in directory_entry::file_size", __ec,
                        make_error_code(__err_kind));
       }
@@ -459,7 +459,7 @@ class directory_entry {
     case _IterNonSymlink:
     case _IterSymlink:
     case _RefreshSymlinkUnresolved:
-      return _VSTD_FS::__hard_link_count(__p_, __ec);
+      return filesystem::__hard_link_count(__p_, __ec);
     case _RefreshSymlink:
     case _RefreshNonSymlink: {
       error_code __m_ec;
@@ -478,13 +478,13 @@ class directory_entry {
     case _IterNonSymlink:
     case _IterSymlink:
     case _RefreshSymlinkUnresolved:
-      return _VSTD_FS::__last_write_time(__p_, __ec);
+      return filesystem::__last_write_time(__p_, __ec);
     case _RefreshSymlink:
     case _RefreshNonSymlink: {
       error_code __m_ec;
       file_status __st(__get_ft(&__m_ec));
       __handle_error("in directory_entry::last_write_time", __ec, __m_ec);
-      if (_VSTD_FS::exists(__st) &&
+      if (filesystem::exists(__st) &&
           __data_.__write_time_ == file_time_type::min())
         __handle_error("in directory_entry::last_write_time", __ec,
                        make_error_code(errc::value_too_large));
@@ -518,7 +518,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP
 
 _LIBCPP_END_NAMESPACE_FILESYSTEM
 
-#endif // !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+#endif // _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
 
 _LIBCPP_POP_MACROS
 
diff --git a/libcxx/include/__filesystem/directory_iterator.h b/libcxx/include/__filesystem/directory_iterator.h
index 632c2c806369b80..9c611a38cfec2a4 100644
--- a/libcxx/include/__filesystem/directory_iterator.h
+++ b/libcxx/include/__filesystem/directory_iterator.h
@@ -29,7 +29,7 @@
 #  pragma GCC system_header
 #endif
 
-#if !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
@@ -156,14 +156,14 @@ _LIBCPP_END_NAMESPACE_FILESYSTEM
 
 template <>
 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY
-inline constexpr bool _VSTD::ranges::enable_borrowed_range<_VSTD_FS::directory_iterator> = true;
+inline constexpr bool _VSTD::ranges::enable_borrowed_range<std::filesystem::directory_iterator> = true;
 
 template <>
 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY
-inline constexpr bool _VSTD::ranges::enable_view<_VSTD_FS::directory_iterator> = true;
+inline constexpr bool _VSTD::ranges::enable_view<std::filesystem::directory_iterator> = true;
 
 #endif // _LIBCPP_STD_VER >= 20
 
-#endif // !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+#endif // _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
 
 #endif // _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H
diff --git a/libcxx/include/__filesystem/directory_options.h b/libcxx/include/__filesystem/directory_options.h
index 699412fbe4b6acc..d176c69c047d4bc 100644
--- a/libcxx/include/__filesystem/directory_options.h
+++ b/libcxx/include/__filesystem/directory_options.h
@@ -17,7 +17,7 @@
 #  pragma GCC system_header
 #endif
 
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER >= 17
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
@@ -73,6 +73,6 @@ inline directory_options& operator^=(directory_options& __lhs,
 
 _LIBCPP_END_NAMESPACE_FILESYSTEM
 
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_STD_VER >= 17
 
 #endif // _LIBCPP___FILESYSTEM_DIRECTORY_OPTIONS_H
diff --git a/libcxx/include/__filesystem/file_status.h b/libcxx/include/__filesystem/file_status.h
index 0cf405b9c29e90c..fc633ab55ae8b99 100644
--- a/libcxx/include/__filesystem/file_status.h
+++ b/libcxx/include/__filesystem/file_status.h
@@ -19,7 +19,7 @@
 #  pragma GCC system_header
 #endif
 
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER >= 17
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
@@ -71,6 +71,6 @@ class _LIBCPP_EXPORTED_FROM_ABI file_status {
 
 _LIBCPP_END_NAMESPACE_FILESYSTEM
 
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_STD_VER >= 17
 
 #endif // _LIBCPP___FILESYSTEM_FILE_STATUS_H
diff --git a/libcxx/include/__filesystem/file_time_type.h b/libcxx/include/__filesystem/file_time_type.h
index 7c4932e603bc1dd..e086dbcc3f51df2 100644
--- a/libcxx/include/__filesystem/file_time_type.h
+++ b/libcxx/include/__filesystem/file_time_type.h
@@ -19,7 +19,7 @@
 #  pragma GCC system_header
 #endif
 
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER >= 17
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
@@ -27,6 +27,6 @@ typedef chrono::time_point<_FilesystemClock> file_time_type;
 
 _LIBCPP_END_NAMESPACE_FILESYSTEM
 
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_STD_VER >= 17
 
 #endif // _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H
diff --git a/libcxx/include/__filesystem/file_type.h b/libcxx/include/__filesystem/file_type.h
index 70ea765d99a0957..f456552db54371c 100644
--- a/libcxx/include/__filesystem/file_type.h
+++ b/libcxx/include/__filesystem/file_type.h
@@ -17,7 +17,7 @@
 #  pragma GCC system_header
 #endif
 
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER >= 17
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
@@ -38,6 +38,6 @@ enum class file_type : signed char {
 
 _LIBCPP_END_NAMESPACE_FILESYSTEM
 
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_STD_VER >= 17
 
 #endif // _LIBCPP___FILESYSTEM_FILE_TYPE_H
diff --git a/libcxx/include/__filesystem/filesystem_error.h b/libcxx/include/__filesystem/filesystem_error.h
index 3ffba1b6c2d6130..d6fb2607e759eef 100644
--- a/libcxx/include/__filesystem/filesystem_error.h
+++ b/libcxx/include/__filesystem/filesystem_error.h
@@ -24,7 +24,7 @@
 #  pragma GCC system_header
 #endif
 
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER >= 17
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
@@ -84,6 +84,6 @@ __throw_filesystem_error(_Args&&...) {
 
 _LIBCPP_END_NAMESPACE_FILESYSTEM
 
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_STD_VER >= 17
 
 #endif // _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H
diff --git a/libcxx/include/__filesystem/operations.h b/libcxx/include/__filesystem/operations.h
index 71b3fb859d49bed..35da7ed0e420a47 100644
--- a/libcxx/include/__filesystem/operations.h
+++ b/libcxx/include/__filesystem/operations.h
@@ -28,7 +28,7 @@
 #  pragma GCC system_header
 #endif
 
-#if !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
@@ -196,6 +196,6 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP
 
 _LIBCPP_END_NAMESPACE_FILESYSTEM
 
-#endif // !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+#endif // _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
 
 #endif // _LIBCPP___FILESYSTEM_OPERATIONS_H
diff --git a/libcxx/include/__filesystem/path.h b/libcxx/include/__filesystem/path.h
index 8a9350be2a00f77..303a5c590585920 100644
--- a/libcxx/include/__filesystem/path.h
+++ b/libcxx/include/__filesystem/path.h
@@ -36,7 +36,7 @@
 #  pragma GCC system_header
 #endif
 
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER >= 17
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
@@ -617,7 +617,7 @@ class _LIBCPP_EXPORTED_FROM_ABI path {
   _EnableIfPathable<_Source> append(const _Source& __src) {
     using _Traits = __is_pathable<_Source>;
     using _CVT = _PathCVT<_SourceChar<_Source> >;
-    bool __source_is_absolute = _VSTD_FS::__is_separator(_Traits::__first_or_null(__src));
+    bool __source_is_absolute = filesystem::__is_separator(_Traits::__first_or_null(__src));
     if (__source_is_absolute)
       __pn_.clear();
     else if (has_filename())
@@ -632,7 +632,7 @@ class _LIBCPP_EXPORTED_FROM_ABI path {
     typedef typename iterator_traits<_InputIt>::value_type _ItVal;
     static_assert(__can_convert_char<_ItVal>::value, "Must convertible");
     using _CVT = _PathCVT<_ItVal>;
-    if (__first != __last && _VSTD_FS::__is_separator(*__first))
+    if (__first != __last && filesystem::__is_separator(*__first))
       __pn_.clear();
     else if (has_filename())
       __pn_ += preferred_separator;
@@ -1083,14 +1083,14 @@ _LIBCPP_END_NAMESPACE_FILESYSTEM
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <>
-struct _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY hash<_VSTD_FS::path> : __unary_function<_VSTD_FS::path, size_t> {
-  _LIBCPP_HIDE_FROM_ABI size_t operator()(_VSTD_FS::path const& __p) const noexcept {
-    return _VSTD_FS::hash_value(__p);
+struct _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY hash<filesystem::path> : __unary_function<filesystem::path, size_t> {
+  _LIBCPP_HIDE_FROM_ABI size_t operator()(filesystem::path const& __p) const noexcept {
+    return filesystem::hash_value(__p);
   }
 };
 
 _LIBCPP_END_NAMESPACE_STD
 
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_STD_VER >= 17
 
 #endif // _LIBCPP___FILESYSTEM_PATH_H
diff --git a/libcxx/include/__filesystem/path_iterator.h b/libcxx/include/__filesystem/path_iterator.h
index 9961b46cf81c0e9..ab8996b10f99974 100644
--- a/libcxx/include/__filesystem/path_iterator.h
+++ b/libcxx/include/__filesystem/path_iterator.h
@@ -23,7 +23,7 @@
 #  pragma GCC system_header
 #endif
 
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER >= 17
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
@@ -127,6 +127,6 @@ inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const path::iterator& __lhs,
 
 _LIBCPP_END_NAMESPACE_FILESYSTEM
 
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_STD_VER >= 17
 
 #endif // _LIBCPP___FILESYSTEM_PATH_ITERATOR_H
diff --git a/libcxx/include/__filesystem/perm_options.h b/libcxx/include/__filesystem/perm_options.h
index 82b73a7f7724ccf..573e05de97c3cab 100644
--- a/libcxx/include/__filesystem/perm_options.h
+++ b/libcxx/include/__filesystem/perm_options.h
@@ -17,7 +17,7 @@
 #  pragma GCC system_header
 #endif
 
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER >= 17
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
@@ -68,6 +68,6 @@ inline perm_options& operator^=(perm_options& __lhs, perm_options __rhs) {
 
 _LIBCPP_END_NAMESPACE_FILESYSTEM
 
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_STD_VER >= 17
 
 #endif // _LIBCPP___FILESYSTEM_PERM_OPTIONS_H
diff --git a/libcxx/include/__filesystem/perms.h b/libcxx/include/__filesystem/perms.h
index f2b5dfaae9d5816..03e1f56f3127ada 100644
--- a/libcxx/include/__filesystem/perms.h
+++ b/libcxx/include/__filesystem/perms.h
@@ -17,7 +17,7 @@
 #  pragma GCC system_header
 #endif
 
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER >= 17
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
@@ -86,6 +86,6 @@ inline perms& operator^=(perms& __lhs, perms __rhs) { return __lhs = __lhs ^ __r
 
 _LIBCPP_END_NAMESPACE_FILESYSTEM
 
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_STD_VER >= 17
 
 #endif // _LIBCPP___FILESYSTEM_PERMS_H
diff --git a/libcxx/include/__filesystem/recursive_directory_iterator.h b/libcxx/include/__filesystem/recursive_directory_iterator.h
index c38d58e50215901..056233bc8382e8a 100644
--- a/libcxx/include/__filesystem/recursive_directory_iterator.h
+++ b/libcxx/include/__filesystem/recursive_directory_iterator.h
@@ -28,7 +28,7 @@
 #  pragma GCC system_header
 #endif
 
-#if !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
@@ -170,14 +170,14 @@ _LIBCPP_END_NAMESPACE_FILESYSTEM
 
 template <>
 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY
-inline constexpr bool _VSTD::ranges::enable_borrowed_range<_VSTD_FS::recursive_directory_iterator> = true;
+inline constexpr bool _VSTD::ranges::enable_borrowed_range<std::filesystem::recursive_directory_iterator> = true;
 
 template <>
 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY
-inline constexpr bool _VSTD::ranges::enable_view<_VSTD_FS::recursive_directory_iterator> = true;
+inline constexpr bool _VSTD::ranges::enable_view<std::filesystem::recursive_directory_iterator> = true;
 
 #endif // _LIBCPP_STD_VER >= 20
 
-#endif // !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+#endif // _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
 
 #endif // _LIBCPP___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H
diff --git a/libcxx/include/__filesystem/space_info.h b/libcxx/include/__filesystem/space_info.h
index 929f5146642441b..2e80ae3b2c11203 100644
--- a/libcxx/include/__filesystem/space_info.h
+++ b/libcxx/include/__filesystem/space_info.h
@@ -18,7 +18,7 @@
 #  pragma GCC system_header
 #endif
 
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER >= 17
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
@@ -34,6 +34,6 @@ struct _LIBCPP_EXPORTED_FROM_ABI space_info {
 
 _LIBCPP_END_NAMESPACE_FILESYSTEM
 
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_STD_VER >= 17
 
 #endif // _LIBCPP___FILESYSTEM_SPACE_INFO_H
diff --git a/libcxx/include/__filesystem/u8path.h b/libcxx/include/__filesystem/u8path.h
index 1db60c3960a8a95..32de20233bac75d 100644
--- a/libcxx/include/__filesystem/u8path.h
+++ b/libcxx/include/__filesystem/u8path.h
@@ -26,7 +26,7 @@
 #  pragma GCC system_header
 #endif
 
-#ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER >= 17
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
@@ -102,6 +102,6 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP
 
 _LIBCPP_END_NAMESPACE_FILESYSTEM
 
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_STD_VER >= 17
 
 #endif // _LIBCPP___FILESYSTEM_U8PATH_H
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 4b777f82efb6cbe..fb5610b0830b614 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -244,7 +244,7 @@ public:
 
 #if _LIBCPP_STD_VER >= 17
     _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_INLINE_VISIBILITY
-    basic_filebuf* open(const _VSTD_FS::path& __p, ios_base::openmode __mode) {
+    basic_filebuf* open(const filesystem::path& __p, ios_base::openmode __mode) {
       return open(__p.c_str(), __mode);
     }
 #endif
diff --git a/libcxx/src/filesystem/directory_entry.cpp b/libcxx/src/filesystem/directory_entry.cpp
index 4910d390d1ea765..a71c2f9d245638b 100644
--- a/libcxx/src/filesystem/directory_entry.cpp
+++ b/libcxx/src/filesystem/directory_entry.cpp
@@ -28,7 +28,7 @@ error_code directory_entry::__do_refresh() noexcept {
     return failure_ec;
   }
 
-  if (!_VSTD_FS::exists(st) || !_VSTD_FS::is_symlink(st)) {
+  if (!filesystem::exists(st) || !filesystem::is_symlink(st)) {
     __data_.__cache_type_ = directory_entry::_RefreshNonSymlink;
     __data_.__type_ = st.type();
     __data_.__non_sym_perms_ = st.permissions();
@@ -54,10 +54,10 @@ error_code directory_entry::__do_refr...
[truncated]

@philnik777
Copy link
Contributor

According to https://sourcegraph.com/search?q=context:global+std::__fs::filesystem+-file:__config&patternType=standard&sm=0&groupBy=repo it looks like this hasn't been used a lot, but it's not like nobody ever used this. Maybe we should deprecate things for one release?

@ldionne
Copy link
Member Author

ldionne commented Nov 20, 2023

@EricWF You probably have more context here?

@EricWF
Copy link
Member

EricWF commented Nov 21, 2023

I believe this was to allow C++17 symbols to appear when C++17 wasn't always available. I'm fine getting rid of it without deprecation.

Let's not teach people to touch our private parts.

@ldionne ldionne force-pushed the review/filesystem-namespace-fix branch from c23016d to 835e2f5 Compare November 23, 2023 22:58
Copy link

github-actions bot commented Nov 23, 2023

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff e7f5d609dd7ec73f9e098532d3fa73b9fa4be02d d76d13545be26ddefc2096927c20022f91956224 -- libcxx/benchmarks/filesystem.bench.cpp libcxx/include/__chrono/file_clock.h libcxx/include/__config libcxx/include/__filesystem/copy_options.h libcxx/include/__filesystem/directory_entry.h libcxx/include/__filesystem/directory_iterator.h libcxx/include/__filesystem/directory_options.h libcxx/include/__filesystem/file_status.h libcxx/include/__filesystem/file_time_type.h libcxx/include/__filesystem/file_type.h libcxx/include/__filesystem/filesystem_error.h libcxx/include/__filesystem/operations.h libcxx/include/__filesystem/path.h libcxx/include/__filesystem/path_iterator.h libcxx/include/__filesystem/perm_options.h libcxx/include/__filesystem/perms.h libcxx/include/__filesystem/recursive_directory_iterator.h libcxx/include/__filesystem/space_info.h libcxx/include/__filesystem/u8path.h libcxx/include/fstream libcxx/src/filesystem/directory_entry.cpp libcxx/src/filesystem/file_descriptor.h libcxx/test/libcxx/input.output/filesystems/class.directory_entry/directory_entry.mods/last_write_time.pass.cpp libcxx/test/libcxx/input.output/filesystems/class.path/path.itr/assert.iterator.pass.cpp libcxx/test/libcxx/input.output/filesystems/class.path/path.member/path.native.obs/string_alloc.pass.cpp libcxx/test/libcxx/input.output/filesystems/class.path/path.req/is_pathable.pass.cpp libcxx/test/libcxx/input.output/filesystems/convert_file_time.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/copy.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/copy_assign.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/default.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/default_const.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/move.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/move_assign.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.io/directory_entry.io.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/refresh.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/replace_filename.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/comparisons.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/path.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/status.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/symlink_status.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/copy.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/copy_assign.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/default_ctor.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/equal.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/increment.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/move.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/move_assign.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.nonmembers/begin_end.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_iterator/iterator_concept_conformance.compile.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_iterator/range_concept_conformance.compile.pass.cpp libcxx/test/std/input.output/filesystems/class.directory_iterator/types.pass.cpp libcxx/test/std/input.output/filesystems/class.file_status/file_status.cons.pass.cpp libcxx/test/std/input.output/filesystems/class.file_status/file_status.mods.pass.cpp libcxx/test/std/input.output/filesystems/class.file_status/file_status.obs.pass.cpp libcxx/test/std/input.output/filesystems/class.filesystem_error/filesystem_error.members.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.itr/iterator.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.append.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.assign/copy.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.assign/move.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.assign/source.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.charconv.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.compare.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.concat.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.construct/copy.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.construct/default.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.construct/move.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.construct/source.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.decompose/empty.verify.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.decompose/path.decompose.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_normal.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_relative_and_proximate.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.generic.obs/generic_string_alloc.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.generic.obs/named_overloads.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.hash_enabled.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/clear.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/make_preferred.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/remove_filename.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/replace_extension.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/replace_filename.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/swap.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.native.obs/c_str.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.native.obs/named_overloads.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.native.obs/native.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.native.obs/operator_string.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.member/path.query/tested_in_path_decompose.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.nonmember/append_op.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.nonmember/append_op.verify.cpp libcxx/test/std/input.output/filesystems/class.path/path.nonmember/comparison_ops.verify.cpp libcxx/test/std/input.output/filesystems/class.path/path.nonmember/comparison_ops_tested_elsewhere.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.nonmember/path.factory.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.nonmember/path.io.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.nonmember/path.io.unicode_bug.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path.nonmember/swap.pass.cpp libcxx/test/std/input.output/filesystems/class.path/path_helper.h libcxx/test/std/input.output/filesystems/class.path/range_concept_conformance.compile.pass.cpp libcxx/test/std/input.output/filesystems/class.path/synop.pass.cpp libcxx/test/std/input.output/filesystems/class.rec.dir.itr/range_concept_conformance.compile.pass.cpp libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy.pass.cpp libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy_assign.pass.cpp libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/depth.pass.cpp libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/disable_recursion_pending.pass.cpp libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/equal.pass.cpp libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/move.pass.cpp libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/move_assign.pass.cpp libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/pop.pass.cpp libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.nonmembers/begin_end.pass.cpp libcxx/test/std/input.output/filesystems/fs.enum/enum.copy_options.pass.cpp libcxx/test/std/input.output/filesystems/fs.enum/enum.directory_options.pass.cpp libcxx/test/std/input.output/filesystems/fs.enum/enum.file_type.pass.cpp libcxx/test/std/input.output/filesystems/fs.enum/enum.path.format.pass.cpp libcxx/test/std/input.output/filesystems/fs.enum/enum.perm_options.pass.cpp libcxx/test/std/input.output/filesystems/fs.enum/enum.perms.pass.cpp libcxx/test/std/input.output/filesystems/fs.filesystem.synopsis/file_time_type.pass.cpp libcxx/test/std/input.output/filesystems/fs.filesystem.synopsis/file_time_type_resolution.compile.pass.cpp libcxx/test/std/input.output/filesystems/fs.filesystem.synopsis/space_info.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.absolute/absolute.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.canonical/canonical.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file_large.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_symlink/copy_symlink.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directory/create_directory_with_attributes.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directory_symlink/create_directory_symlink.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_hard_link/create_hard_link.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_symlink/create_symlink.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.current_path/current_path.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.equivalent/equivalent.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.exists/exists.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.file_size/file_size.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_block_file/is_block_file.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_char_file/is_character_file.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_directory/is_directory.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_fifo/is_fifo.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_other/is_other.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_regular_file/is_regular_file.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_socket/is_socket.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_symlink/is_symlink.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.permissions/permissions.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.proximate/proximate.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.read_symlink/read_symlink.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.relative/relative.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.remove/remove.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.remove_all/remove_all.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.remove_all/toctou.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.rename/rename.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.resize_file/resize_file.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.space/space.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.status/status.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.status_known/status_known.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.symlink_status/symlink_status.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp libcxx/test/support/filesystem_test_helper.h
View the diff from clang-format here.
diff --git a/libcxx/include/__filesystem/directory_entry.h b/libcxx/include/__filesystem/directory_entry.h
index e02946a7ee..13fc442440 100644
--- a/libcxx/include/__filesystem/directory_entry.h
+++ b/libcxx/include/__filesystem/directory_entry.h
@@ -103,8 +103,7 @@ public:
   _LIBCPP_INLINE_VISIBILITY
   operator const _Path&() const noexcept { return __p_; }
 
-  _LIBCPP_INLINE_VISIBILITY
-  bool exists() const { return filesystem::exists(file_status{__get_ft()}); }
+  _LIBCPP_INLINE_VISIBILITY bool exists() const { return filesystem::exists(file_status{__get_ft()}); }
 
   _LIBCPP_INLINE_VISIBILITY
   bool exists(error_code& __ec) const noexcept {
@@ -143,8 +142,7 @@ public:
     return __get_ft(&__ec) == file_type::fifo;
   }
 
-  _LIBCPP_INLINE_VISIBILITY
-  bool is_other() const { return filesystem::is_other(file_status{__get_ft()}); }
+  _LIBCPP_INLINE_VISIBILITY bool is_other() const { return filesystem::is_other(file_status{__get_ft()}); }
 
   _LIBCPP_INLINE_VISIBILITY
   bool is_other(error_code& __ec) const noexcept {
@@ -441,8 +439,7 @@ private:
       file_status __st(__get_ft(&__m_ec));
       __handle_error("in directory_entry::file_size", __ec, __m_ec);
       if (filesystem::exists(__st) && !filesystem::is_regular_file(__st)) {
-        errc __err_kind = filesystem::is_directory(__st) ? errc::is_a_directory
-                                                         : errc::not_supported;
+        errc __err_kind = filesystem::is_directory(__st) ? errc::is_a_directory : errc::not_supported;
         __handle_error("in directory_entry::file_size", __ec,
                        make_error_code(__err_kind));
       }
@@ -484,8 +481,7 @@ private:
       error_code __m_ec;
       file_status __st(__get_ft(&__m_ec));
       __handle_error("in directory_entry::last_write_time", __ec, __m_ec);
-      if (filesystem::exists(__st) &&
-          __data_.__write_time_ == file_time_type::min())
+      if (filesystem::exists(__st) && __data_.__write_time_ == file_time_type::min())
         __handle_error("in directory_entry::last_write_time", __ec,
                        make_error_code(errc::value_too_large));
       return __data_.__write_time_;
diff --git a/libcxx/include/__filesystem/directory_iterator.h b/libcxx/include/__filesystem/directory_iterator.h
index 9c611a38cf..1060cddbb2 100644
--- a/libcxx/include/__filesystem/directory_iterator.h
+++ b/libcxx/include/__filesystem/directory_iterator.h
@@ -155,14 +155,14 @@ _LIBCPP_END_NAMESPACE_FILESYSTEM
 #if _LIBCPP_STD_VER >= 20
 
 template <>
-_LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY
-inline constexpr bool _VSTD::ranges::enable_borrowed_range<std::filesystem::directory_iterator> = true;
+_LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY inline constexpr bool
+    _VSTD::ranges::enable_borrowed_range<std::filesystem::directory_iterator> = true;
 
 template <>
-_LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY
-inline constexpr bool _VSTD::ranges::enable_view<std::filesystem::directory_iterator> = true;
+_LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY inline constexpr bool
+    _VSTD::ranges::enable_view<std::filesystem::directory_iterator> = true;
 
-#endif // _LIBCPP_STD_VER >= 20
+#  endif // _LIBCPP_STD_VER >= 20
 
 #endif // _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
 
diff --git a/libcxx/include/__filesystem/recursive_directory_iterator.h b/libcxx/include/__filesystem/recursive_directory_iterator.h
index 056233bc83..b6fbe9a0c7 100644
--- a/libcxx/include/__filesystem/recursive_directory_iterator.h
+++ b/libcxx/include/__filesystem/recursive_directory_iterator.h
@@ -169,14 +169,14 @@ _LIBCPP_END_NAMESPACE_FILESYSTEM
 #if _LIBCPP_STD_VER >= 20
 
 template <>
-_LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY
-inline constexpr bool _VSTD::ranges::enable_borrowed_range<std::filesystem::recursive_directory_iterator> = true;
+_LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY inline constexpr bool
+    _VSTD::ranges::enable_borrowed_range<std::filesystem::recursive_directory_iterator> = true;
 
 template <>
-_LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY
-inline constexpr bool _VSTD::ranges::enable_view<std::filesystem::recursive_directory_iterator> = true;
+_LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY inline constexpr bool
+    _VSTD::ranges::enable_view<std::filesystem::recursive_directory_iterator> = true;
 
-#endif // _LIBCPP_STD_VER >= 20
+#  endif // _LIBCPP_STD_VER >= 20
 
 #endif // _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
 
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/default_ctor.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/default_ctor.pass.cpp
index 47a8d1bdcb..ace9dc93be 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/default_ctor.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/default_ctor.pass.cpp
@@ -16,7 +16,6 @@
 
 // directory_iterator::directory_iterator() noexcept
 
-
 #include <filesystem>
 #include <type_traits>
 #include <cassert>
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_iterator/types.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_iterator/types.pass.cpp
index 46bd6d11ff..3eb6462fcb 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_iterator/types.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_iterator/types.pass.cpp
@@ -28,7 +28,6 @@
 #include "test_macros.h"
 namespace fs = std::filesystem;
 
-
 int main(int, char**) {
     using namespace fs;
     using D = directory_iterator;
diff --git a/libcxx/test/std/input.output/filesystems/class.path/path.itr/iterator.pass.cpp b/libcxx/test/std/input.output/filesystems/class.path/path.itr/iterator.pass.cpp
index 120b0ee953..b83b6fe703 100644
--- a/libcxx/test/std/input.output/filesystems/class.path/path.itr/iterator.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.path/path.itr/iterator.pass.cpp
@@ -18,7 +18,6 @@
 // template <class InputIterator>
 //      path(InputIterator first, InputIterator last);
 
-
 #include <filesystem>
 #include <cassert>
 #include <iterator>
diff --git a/libcxx/test/std/input.output/filesystems/class.path/path.member/path.decompose/path.decompose.pass.cpp b/libcxx/test/std/input.output/filesystems/class.path/path.member/path.decompose/path.decompose.pass.cpp
index 6013172e0c..274659f4bd 100644
--- a/libcxx/test/std/input.output/filesystems/class.path/path.member/path.decompose/path.decompose.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.path/path.member/path.decompose/path.decompose.pass.cpp
@@ -43,7 +43,6 @@
 // iterator begin() const;
 // iterator end() const;
 
-
 #include <filesystem>
 #include <algorithm>
 #include <cassert>

@ldionne
Copy link
Member Author

ldionne commented Nov 23, 2023

Note that I'm going to ignore the formatting changes cause I feel they just create confusion if I include them in this patch.

<filesystem> is a C++17 addition. In C++11 and C++14 modes, we actually
have all the code for <filesystem> but it is hidden behind a non-inline
namespace __fs so it is not accessible. Instead of doing this unusual
dance, just guard the code for filesystem behind a classic C++17 check
like we normally do.
@ldionne ldionne force-pushed the review/filesystem-namespace-fix branch from 1e000a8 to d76d135 Compare November 28, 2023 23:36
Copy link
Contributor

@philnik777 philnik777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you both think it's fine to do this without deprecation this is also fine by me. It's always nice to simplify the library a bit.

@ldionne
Copy link
Member Author

ldionne commented Nov 28, 2023

I considered the risk of breakage here some more, and we're not removing the std::__fs::filesystem namespace (since that would be ABI-breaking). So most of these code examples would still work even after this patch, but not if they were trying to use filesystem in C++14. Given that mainline Clang is now using C++17 by default, I think this is unlikely to bite that many people.

@ldionne ldionne merged commit ac8c9f1 into llvm:main Nov 28, 2023
@ldionne ldionne deleted the review/filesystem-namespace-fix branch November 28, 2023 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants