diff options
author | David Spickett <david.spickett@linaro.org> | 2022-07-21 15:36:52 +0000 |
---|---|---|
committer | David Spickett <david.spickett@linaro.org> | 2022-07-25 08:19:28 +0000 |
commit | 3a35bcef222844c20efa450cc1b47e96aa9be9b0 (patch) | |
tree | 789be8e2988dc3de058b19ec2b61e0b71cd1244b /llvm/lib/FileCheck/FileCheck.cpp | |
parent | fb7caa3c7b53a4362139afe0158f297a891cc17b (diff) | |
download | llvm-3a35bcef222844c20efa450cc1b47e96aa9be9b0.zip llvm-3a35bcef222844c20efa450cc1b47e96aa9be9b0.tar.gz llvm-3a35bcef222844c20efa450cc1b47e96aa9be9b0.tar.bz2 |
[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
Diffstat (limited to 'llvm/lib/FileCheck/FileCheck.cpp')
-rw-r--r-- | llvm/lib/FileCheck/FileCheck.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp index bf13b6c..5d4cfce 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(); |