From 3a35bcef222844c20efa450cc1b47e96aa9be9b0 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Thu, 21 Jul 2022 15:36:52 +0000 Subject: [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 --- llvm/lib/FileCheck/FileCheck.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'llvm/lib/FileCheck/FileCheck.cpp') 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(); -- cgit v1.1