From 58f427ee41fc0623c68b0d777b973339fbe73a26 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 19 Feb 2013 09:28:55 +0000 Subject: [PATCH] Fix bug in LineState comparison function. The key bug was if (Other.StartOfLineLevel < StartOfLineLevel) .. instead of if (Other.StartOfLineLevel != StartOfLineLevel) .. Also cleaned up the function to be more consistent in the comparisons. llvm-svn: 175500 --- clang/lib/Format/Format.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index d8ef5cf785ca..8421a3b63e47 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -394,20 +394,20 @@ private: /// \brief Comparison operator to be able to used \c LineState in \c map. bool operator<(const LineState &Other) const { - if (Other.NextToken != NextToken) - return Other.NextToken > NextToken; - if (Other.Column != Column) - return Other.Column > Column; - if (Other.VariablePos != VariablePos) - return Other.VariablePos < VariablePos; - if (Other.LineContainsContinuedForLoopSection != - LineContainsContinuedForLoopSection) + if (NextToken != Other.NextToken) + return NextToken < Other.NextToken; + if (Column != Other.Column) + return Column < Other.Column; + if (VariablePos != Other.VariablePos) + return VariablePos < Other.VariablePos; + if (LineContainsContinuedForLoopSection != + Other.LineContainsContinuedForLoopSection) return LineContainsContinuedForLoopSection; - if (Other.ParenLevel != ParenLevel) - return Other.ParenLevel < ParenLevel; - if (Other.StartOfLineLevel < StartOfLineLevel) - return Other.StartOfLineLevel < StartOfLineLevel; - return Other.Stack < Stack; + if (ParenLevel != Other.ParenLevel) + return ParenLevel < Other.ParenLevel; + if (StartOfLineLevel != Other.StartOfLineLevel) + return StartOfLineLevel < Other.StartOfLineLevel; + return Stack < Other.Stack; } };