]> granicus.if.org Git - clang/commitdiff
clang-format: Improve address-of-operator detection
authorDaniel Jasper <djasper@google.com>
Sat, 21 Sep 2013 17:31:51 +0000 (17:31 +0000)
committerDaniel Jasper <djasper@google.com>
Sat, 21 Sep 2013 17:31:51 +0000 (17:31 +0000)
Before:
  size = sizeof * a;

After:
  size = sizeof *a;

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

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

index 0f9f57802452059dfbd69a3f19f1abc41f7f1f54..6386bc16dd318ec62cb4e8ca7da4bd3f62a511b8 100644 (file)
@@ -737,7 +737,7 @@ private:
 
     if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
                            tok::comma, tok::semi, tok::kw_return, tok::colon,
-                           tok::equal, tok::kw_delete) ||
+                           tok::equal, tok::kw_delete, tok::kw_sizeof) ||
         PrevToken->Type == TT_BinaryOperator ||
         PrevToken->Type == TT_UnaryOperator || PrevToken->Type == TT_CastRParen)
       return TT_UnaryOperator;
index fc13ad150ba0dcda2308f1ff29b5f4cadcc47963..a1136825b1bb31cf8c4c68a6f931bc7f16cf9361 100644 (file)
@@ -3851,6 +3851,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
   verifyIndependentOfContext("if (*b[i])");
   verifyIndependentOfContext("if (int *a = (&b))");
   verifyIndependentOfContext("while (int *a = &b)");
+  verifyIndependentOfContext("size = sizeof *a;");
   verifyFormat("void f() {\n"
                "  for (const int &v : Values) {\n"
                "  }\n"