[PATCH] D63962: [clang-doc] Fix segfault in comment sorting

Julie Hockett via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 2 10:57:26 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL364949: [clang-doc] Fix segfault in comment sorting (authored by juliehockett, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63962?vs=207170&id=207591#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63962/new/

https://reviews.llvm.org/D63962

Files:
  clang-tools-extra/trunk/clang-doc/Representation.h


Index: clang-tools-extra/trunk/clang-doc/Representation.h
===================================================================
--- clang-tools-extra/trunk/clang-doc/Representation.h
+++ clang-tools-extra/trunk/clang-doc/Representation.h
@@ -75,15 +75,16 @@
                  Other.ParamName, Other.CloseName, Other.SelfClosing,
                  Other.Explicit, Other.AttrKeys, Other.AttrValues, Other.Args);
 
-    if (FirstCI < SecondCI ||
-        (FirstCI == SecondCI && Children.size() < Other.Children.size()))
+    if (FirstCI < SecondCI)
       return true;
 
-    if (FirstCI > SecondCI || Children.size() > Other.Children.size())
-      return false;
+    if (FirstCI == SecondCI) {
+      return std::lexicographical_compare(
+          Children.begin(), Children.end(), Other.Children.begin(),
+          Other.Children.end(), llvm::deref<llvm::less>());
+    }
 
-    return std::equal(Children.begin(), Children.end(), Other.Children.begin(),
-                      llvm::deref<llvm::less>{});
+    return false;
   }
 
   SmallString<16>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63962.207591.patch
Type: text/x-patch
Size: 1052 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190702/62762bc0/attachment.bin>


More information about the cfe-commits mailing list