[llvm] 3a35bce - [llvm][FileCheck] Fix unit tests failures with EXPENSIVE_CHECKS
David Spickett via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 25 01:19:32 PDT 2022
Author: David Spickett
Date: 2022-07-25T08:19:28Z
New Revision: 3a35bcef222844c20efa450cc1b47e96aa9be9b0
URL: https://github.com/llvm/llvm-project/commit/3a35bcef222844c20efa450cc1b47e96aa9be9b0
DIFF: https://github.com/llvm/llvm-project/commit/3a35bcef222844c20efa450cc1b47e96aa9be9b0.diff
LOG: [llvm][FileCheck] Fix unit tests failures with EXPENSIVE_CHECKS
EXPENSIVE_CHECKS enables _GLIBCXX_DEBUG, which makes std::sort
check that the compare function is implemented correctly.
To do this it calls it with the first item as both sides.
Which trips the assert here because we think they're
2 capture ranges that overlap, when it's just the same range twice.
Check up front for the two sides being the same item
(same address, not just ==).
Reviewed By: kazu
Differential Revision: https://reviews.llvm.org/D130282
Added:
Modified:
llvm/lib/FileCheck/FileCheck.cpp
Removed:
################################################################################
diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp
index bf13b6c325ecf..5d4cfceefb3ea 100644
--- a/llvm/lib/FileCheck/FileCheck.cpp
+++ b/llvm/lib/FileCheck/FileCheck.cpp
@@ -1424,6 +1424,8 @@ void Pattern::printVariableDefs(const SourceMgr &SM,
// Sort variable captures by the order in which they matched the input.
// Ranges shouldn't be overlapping, so we can just compare the start.
llvm::sort(VarCaptures, [](const VarCapture &A, const VarCapture &B) {
+ if (&A == &B)
+ return false;
assert(A.Range.Start != B.Range.Start &&
"unexpected overlapping variable captures");
return A.Range.Start.getPointer() < B.Range.Start.getPointer();
More information about the llvm-commits
mailing list