[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

Paul Kirth via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 1 13:05:34 PDT 2024


================
@@ -312,6 +317,16 @@ struct SymbolInfo : public Info {
 
   std::optional<Location> DefLoc;     // Location where this decl is defined.
   llvm::SmallVector<Location, 2> Loc; // Locations where this decl is declared.
+
+  bool operator<(const SymbolInfo &Other) const {
+    if (DefLoc && Other.DefLoc) {
+      return *DefLoc < *Other.DefLoc;
+    }
+    if (Loc.size() > 0 && Other.Loc.size() > 0) {
+      return Loc[0] < Other.Loc[0];
+    }
+    return extractName() < Other.extractName();
+  }
----------------
ilovepi wrote:

Can you add some comments about this comparison. It seems you're ordering by DefLoc, then Loc, and lastly by Name, but why that's a good/reasonable ordering isn't obvious.

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


More information about the cfe-commits mailing list