[clang-tools-extra] 8aa88ee - [clangd] Fix the flaky FindTarget unittest after 1b66840

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 27 00:48:52 PDT 2023


Author: Haojian Wu
Date: 2023-06-27T09:48:41+02:00
New Revision: 8aa88ee5e01df0daf08a3768fbf23fe655ad81c0

URL: https://github.com/llvm/llvm-project/commit/8aa88ee5e01df0daf08a3768fbf23fe655ad81c0
DIFF: https://github.com/llvm/llvm-project/commit/8aa88ee5e01df0daf08a3768fbf23fe655ad81c0.diff

LOG: [clangd] Fix the flaky FindTarget unittest after 1b66840

after 1b66840, FindTarget will report multiple refs with the same
location, make the sort order of the refs deterministic in
FindTargetTests.

Added: 
    

Modified: 
    clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 64ac524fc5187..19e80658de063 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1241,7 +1241,7 @@ class FindExplicitReferencesTest : public ::testing::Test {
   AllRefs annotatedReferences(llvm::StringRef Code, ParsedAST &AST,
                               std::vector<ReferenceLoc> Refs) {
     auto &SM = AST.getSourceManager();
-    llvm::sort(Refs, [&](const ReferenceLoc &L, const ReferenceLoc &R) {
+    llvm::stable_sort(Refs, [&](const ReferenceLoc &L, const ReferenceLoc &R) {
       return SM.isBeforeInTranslationUnit(L.NameLoc, R.NameLoc);
     });
 


        


More information about the cfe-commits mailing list