Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / src / filesystem / filesystem_error.cpp
blob5faed3b89efa608ec92451e3a209f24a7c21654b
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include <__config>
10 #include <__utility/unreachable.h>
11 #include <filesystem>
12 #include <system_error>
14 #include "format_string.h"
16 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
18 filesystem_error::~filesystem_error() {}
20 void filesystem_error::__create_what(int __num_paths) {
21 const char* derived_what = system_error::what();
22 __storage_->__what_ = [&]() -> string {
23 switch (__num_paths) {
24 case 0:
25 return detail::format_string("filesystem error: %s", derived_what);
26 case 1:
27 return detail::format_string("filesystem error: %s [" PATH_CSTR_FMT "]",
28 derived_what, path1().c_str());
29 case 2:
30 return detail::format_string("filesystem error: %s [" PATH_CSTR_FMT "] [" PATH_CSTR_FMT "]",
31 derived_what, path1().c_str(), path2().c_str());
33 __libcpp_unreachable();
34 }();
37 _LIBCPP_END_NAMESPACE_FILESYSTEM