From 65da8e952da32730202356290bb889c8839bbef5 Mon Sep 17 00:00:00 2001
From: Daniel Jasper <djasper@google.com>
Date: Sat, 21 Sep 2013 17:31:51 +0000
Subject: [PATCH] clang-format: Improve address-of-operator detection

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   | 2 +-
 unittests/Format/FormatTest.cpp | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 0f9f5780245..6386bc16dd3 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -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;
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index fc13ad150ba..a1136825b1b 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -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"
-- 
GitLab