[clang] [APINotes] Avoid assertion failure with expensive checks (PR #120487)

via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 18 14:28:38 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 5ca3794e82bd4d96e5aa32821bed033e40f51814 b3d95e794735c3f8242643c3d187c24a1ad51421 --extensions cpp -- clang/lib/APINotes/APINotesReader.cpp
``````````

</details>

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

``````````diff
diff --git a/clang/lib/APINotes/APINotesReader.cpp b/clang/lib/APINotes/APINotesReader.cpp
index 646eabd2a5..e70146467f 100644
--- a/clang/lib/APINotes/APINotesReader.cpp
+++ b/clang/lib/APINotes/APINotesReader.cpp
@@ -2041,18 +2041,19 @@ APINotesReader::VersionedInfo<T>::VersionedInfo(
     : Results(std::move(R)) {
 
   assert(!Results.empty());
-  assert(std::is_sorted(
-      Results.begin(), Results.end(),
-      [](const std::pair<llvm::VersionTuple, T> &left,
-         const std::pair<llvm::VersionTuple, T> &right) -> bool {
-        // The comparison function should be reflective, and with expensive
-        // checks we can get callbacks basically checking that lambda(a,a) is
-        // false. We could still check that we do not find equal elements when
-        // left!=right.
-        assert((&left == &right || left.first != right.first) &&
-               "two entries for the same version");
-        return left.first < right.first;
-      }));
+  assert(
+      std::is_sorted(Results.begin(), Results.end(),
+                     [](const std::pair<llvm::VersionTuple, T> &left,
+                        const std::pair<llvm::VersionTuple, T> &right) -> bool {
+                       // The comparison function should be reflective, and with
+                       // expensive checks we can get callbacks basically
+                       // checking that lambda(a,a) is false. We could still
+                       // check that we do not find equal elements when
+                       // left!=right.
+                       assert((&left == &right || left.first != right.first) &&
+                              "two entries for the same version");
+                       return left.first < right.first;
+                     }));
 
   Selected = std::nullopt;
   for (unsigned i = 0, n = Results.size(); i != n; ++i) {

``````````

</details>


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


More information about the cfe-commits mailing list