[libcxx-commits] [libcxx] Heres the minimal contracts in libc++ (PR #98187)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 9 09:52:36 PDT 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 2a086dce691e3cc34a2fc27f4fb255bb2cbbfac9 843cd2ef0fbb095b933dea677dcb8e515759f140 -- libcxx/include/contracts libcxx/src/contracts.cpp libcxx/test/std/contracts/breathing_test.pass.cpp libcxx/include/__assert libcxx/test/libcxx/assertions/modes/override_with_extensive_mode.pass.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/src/contracts.cpp b/libcxx/src/contracts.cpp
index 958660376d..3f22ada902 100644
--- a/libcxx/src/contracts.cpp
+++ b/libcxx/src/contracts.cpp
@@ -3,9 +3,6 @@
 #include <exception>
 #include <iostream>
 
-
-
-
 namespace std::contracts {
 
 void invoke_default_contract_violation_handler(const contract_violation& violation) noexcept {
@@ -60,13 +57,14 @@ _LIBCPP_EXPORTED_FROM_ABI void __handle_contract_violation(
   using namespace std::contracts;
 
   using _InfoT = std::contracts::contract_violation::_Info;
-  _InfoT info = {.__kind_ = static_cast<_AssertKind>(kind),
-                 .__semantic_ = static_cast<_EvaluationSemantic>(eval_semantic),
-                 .__detection_mode_ = static_cast<_DetectionMode>(detection_mode),
-                 .__comment_ = comment,
-                 .__file_name_ = file,
-                 .__function_name_ = nullptr,
-                 .__line_ = line};
+  _InfoT info  = {
+       .__kind_           = static_cast<_AssertKind>(kind),
+       .__semantic_       = static_cast<_EvaluationSemantic>(eval_semantic),
+       .__detection_mode_ = static_cast<_DetectionMode>(detection_mode),
+       .__comment_        = comment,
+       .__file_name_      = file,
+       .__function_name_  = nullptr,
+       .__line_           = line};
   contract_violation violation(info);
   if (::handle_contract_violation)
     ::handle_contract_violation(violation);
diff --git a/libcxx/test/std/contracts/breathing_test.pass.cpp b/libcxx/test/std/contracts/breathing_test.pass.cpp
index 3f14ee7771..87fb5c8957 100644
--- a/libcxx/test/std/contracts/breathing_test.pass.cpp
+++ b/libcxx/test/std/contracts/breathing_test.pass.cpp
@@ -3,10 +3,7 @@
 
 using std::contracts::contract_violation;
 
-void test(int x) pre(x != 1) {
-  contract_assert(x != 0);
-}
-
+void test(int x) pre(x != 1) { contract_assert(x != 0); }
 
 int main() {
   test(2);

``````````

</details>


https://github.com/llvm/llvm-project/pull/98187


More information about the libcxx-commits mailing list