[libcxx-commits] [libcxx] (Draft to check CI, please ignore) (PR #78539)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jan 17 19:11:06 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 8dfc67d6724eb0af5d278f4d1d5511ca9f9e039f eef9a28114a8b224a28d72c6f8ceb4112344a78c -- libcxx/test/libcxx/assertions/customize_verbose_abort.compile-time.pass.cpp libcxx/test/libcxx/assertions/customize_verbose_abort.link-time.pass.cpp libcxx/test/libcxx/assertions/default_verbose_abort.pass.cpp libcxx/test/support/check_assertion.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/test/support/check_assertion.h b/libcxx/test/support/check_assertion.h
index 862e212806..055a48ef3e 100644
--- a/libcxx/test/support/check_assertion.h
+++ b/libcxx/test/support/check_assertion.h
@@ -41,9 +41,7 @@ struct AssertionInfoMatcher {
static constexpr const char* any_msg = "*";
constexpr AssertionInfoMatcher()
- : msg_(any_msg, __builtin_strlen(any_msg)),
- file_(any_file, __builtin_strlen(any_file)),
- line_(any_line) {}
+ : msg_(any_msg, __builtin_strlen(any_msg)), file_(any_file, __builtin_strlen(any_file)), line_(any_line) {}
constexpr AssertionInfoMatcher(const char* msg, const char* file = any_file, int line = any_line)
: is_empty_(false), msg_(msg, __builtin_strlen(msg)), file_(file, __builtin_strlen(file)), line_(line) {}
@@ -58,7 +56,7 @@ struct AssertionInfoMatcher {
assert(match_result.size() == 5);
const std::string& file = match_result[1];
- int line = std::stoi(match_result[2]);
+ int line = std::stoi(match_result[2]);
// Omitting `expression` in `match_result[3]`
const std::string& failure_reason = match_result[4];
@@ -76,9 +74,9 @@ struct AssertionInfoMatcher {
std::string FormatMatchingError(const std::string& file, int line, const std::string& message) const {
std::stringstream output;
- output //
- << "Expected message: '" << msg_.data() << "'\n" //
- << "Actual message: '" << message.c_str() << "'\n" //
+ output //
+ << "Expected message: '" << msg_.data() << "'\n" //
+ << "Actual message: '" << message.c_str() << "'\n" //
<< "Expected location: " << FormatLocation(file_, line_) << "\n" //
<< "Actual location: " << FormatLocation(file, line) << "\n";
return output.str();
@@ -92,9 +90,7 @@ struct AssertionInfoMatcher {
}
bool empty() const { return is_empty_; }
- bool IsAnyMatcher() const {
- return msg_ == any_msg && file_ == any_file && line_ == any_line;
- }
+ bool IsAnyMatcher() const { return msg_ == any_msg && file_ == any_file && line_ == any_line; }
private:
bool CheckLineMatches(int got_line) const {
@@ -133,7 +129,8 @@ private:
}
private:
- bool is_empty_ = true;;
+ bool is_empty_ = true;
+ ;
std::string_view msg_;
std::string_view file_;
int line_;
@@ -154,31 +151,29 @@ enum class DeathCause {
bool IsValidCause(DeathCause cause) {
switch (cause) {
- case DeathCause::VerboseAbort:
- case DeathCause::StdTerminate:
- case DeathCause::Trap:
- return true;
- default:
- return false;
+ case DeathCause::VerboseAbort:
+ case DeathCause::StdTerminate:
+ case DeathCause::Trap:
+ return true;
+ default:
+ return false;
}
}
std::string ToString(DeathCause cause) {
switch (cause) {
- case DeathCause::VerboseAbort:
- return "verbose abort";
- case DeathCause::StdTerminate:
- return "`std::terminate`";
- case DeathCause::Trap:
- return "trap";
- default:
- return "<invalid cause>";
+ case DeathCause::VerboseAbort:
+ return "verbose abort";
+ case DeathCause::StdTerminate:
+ return "`std::terminate`";
+ case DeathCause::Trap:
+ return "trap";
+ default:
+ return "<invalid cause>";
}
}
-TEST_NORETURN void StopChildProcess(DeathCause cause) {
- std::exit(static_cast<int>(cause));
-}
+TEST_NORETURN void StopChildProcess(DeathCause cause) { std::exit(static_cast<int>(cause)); }
DeathCause ConvertToDeathCause(int val) {
if (val < static_cast<int>(DeathCause::VerboseAbort) || val > static_cast<int>(DeathCause::Unknown)) {
@@ -188,8 +183,8 @@ DeathCause ConvertToDeathCause(int val) {
}
struct DeathTest {
- DeathTest() = default;
- DeathTest(DeathTest const&) = delete;
+ DeathTest() = default;
+ DeathTest(DeathTest const&) = delete;
DeathTest& operator=(DeathTest const&) = delete;
template <class Func>
@@ -289,6 +284,7 @@ private:
int GetStdErrWriteFD() const {
return stderr_pipe_fd_[1];
}
+
private:
pid_t child_pid_ = -1;
int exit_code_ = -1;
@@ -313,9 +309,7 @@ void std::__libcpp_verbose_abort(char const* format, ...) {
}
#endif // _LIBCPP_VERSION
-[[noreturn]] inline void terminate_handler() {
- StopChildProcess(DeathCause::StdTerminate);
-}
+[[noreturn]] inline void terminate_handler() { StopChildProcess(DeathCause::StdTerminate); }
template <class Func>
inline bool ExpectDeath(DeathCause expected_cause, const char* stmt, Func&& func, AssertionInfoMatcher matcher) {
@@ -350,32 +344,32 @@ inline bool ExpectDeath(DeathCause expected_cause, const char* stmt, Func&& func
};
switch (cause) {
- case DeathCause::StdTerminate:
- case DeathCause::Trap:
- if (expected_cause != cause) {
- return OnFailure(CauseMismatchMessage(expected_cause, cause));
- }
- return true;
+ case DeathCause::StdTerminate:
+ case DeathCause::Trap:
+ if (expected_cause != cause) {
+ return OnFailure(CauseMismatchMessage(expected_cause, cause));
+ }
+ return true;
- case DeathCause::VerboseAbort: {
- if (expected_cause != cause) {
- return OnFailure(CauseMismatchMessage(expected_cause, cause));
- }
- std::string maybe_error;
- if (matcher.CheckMatchInOutput(test_case.getChildStdErr(), maybe_error)) {
- return true;
- }
- maybe_error = std::string("Child died, but with a different verbose abort message\n") + maybe_error;
- return OnFailure(maybe_error);
+ case DeathCause::VerboseAbort: {
+ if (expected_cause != cause) {
+ return OnFailure(CauseMismatchMessage(expected_cause, cause));
+ }
+ std::string maybe_error;
+ if (matcher.CheckMatchInOutput(test_case.getChildStdErr(), maybe_error)) {
+ return true;
}
+ maybe_error = std::string("Child died, but with a different verbose abort message\n") + maybe_error;
+ return OnFailure(maybe_error);
+ }
- // Unexpected causes.
- case DeathCause::SetupFailure:
- return OnFailure("Child failed to set up test environment");
- case DeathCause::Unknown:
- return OnFailure("Cause unknown");
- case DeathCause::DidNotDie:
- return OnFailure("Child did not die");
+ // Unexpected causes.
+ case DeathCause::SetupFailure:
+ return OnFailure("Child failed to set up test environment");
+ case DeathCause::Unknown:
+ return OnFailure("Cause unknown");
+ case DeathCause::DidNotDie:
+ return OnFailure("Child did not die");
}
assert(false && "unreachable");
``````````
</details>
https://github.com/llvm/llvm-project/pull/78539
More information about the libcxx-commits
mailing list