]> granicus.if.org Git - clang/commitdiff
Fix bug in LineState comparison function.
authorDaniel Jasper <djasper@google.com>
Tue, 19 Feb 2013 09:28:55 +0000 (09:28 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 19 Feb 2013 09:28:55 +0000 (09:28 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175500 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/Format.cpp

index d8ef5cf785cac4edfa5e8ce0bc9cf20853aa733a..8421a3b63e479a421e4aa917872ea3b0fb849fc1 100644 (file)
@@ -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;
     }
   };