]> granicus.if.org Git - clang/commitdiff
clang-format: Fix incorrect && recognition.
authorDaniel Jasper <djasper@google.com>
Wed, 11 Mar 2015 12:59:49 +0000 (12:59 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 11 Mar 2015 12:59:49 +0000 (12:59 +0000)
Before:
  if (a &&(b = c)) ..

After:
  if (a && (b = c)) ..

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

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp

index b8f8b992ce7ed5253b2df8f03221dbf66f8cfa93..74b7de0001ed2bdf8d1986382a31e4c6c629ff36 100644 (file)
@@ -767,6 +767,8 @@ private:
             if (!Previous)
               break;
           }
+          if (Previous->opensScope())
+            break;
           if (Previous->isOneOf(TT_BinaryOperator, TT_UnaryOperator) &&
               Previous->isOneOf(tok::star, tok::amp, tok::ampamp) &&
               Previous->Previous && Previous->Previous->isNot(tok::equal))
index 7221ec898aa4ed1449c18239dfea431486bffb4b..3e4806f5a23fe16ac0134cb24b518ebc784727f4 100644 (file)
@@ -5371,6 +5371,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
   verifyIndependentOfContext("if (int *a = (&b))");
   verifyIndependentOfContext("while (int *a = &b)");
   verifyIndependentOfContext("size = sizeof *a;");
+  verifyIndependentOfContext("if (a && (b = c))");
   verifyFormat("void f() {\n"
                "  for (const int &v : Values) {\n"
                "  }\n"