Skip to content

Commit

Permalink
[clang-doc] Fix segfault in comment sorting
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D63962

llvm-svn: 364949
  • Loading branch information
Julie Hockett committed Jul 2, 2019
1 parent cffbaa9 commit d42f229
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions clang-tools-extra/clang-doc/Representation.h
Expand Up @@ -75,15 +75,16 @@ struct CommentInfo {
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>
Expand Down

0 comments on commit d42f229

Please sign in to comment.