diff options
author | Daniel Jasper <djasper@google.com> | 2013-09-21 17:31:51 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-09-21 17:31:51 +0000 |
commit | df620b2457adffc95f45874fe42d792a4dca889d (patch) | |
tree | b77de24094c70d5d762a151dd73629ca31ab9b18 | |
parent | f043a65327024edc7f8f6327bba325d827513b9a (diff) | |
download | bcm5719-llvm-df620b2457adffc95f45874fe42d792a4dca889d.tar.gz bcm5719-llvm-df620b2457adffc95f45874fe42d792a4dca889d.zip |
clang-format: Improve address-of-operator detection
Before:
size = sizeof * a;
After:
size = sizeof *a;
llvm-svn: 191139
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 0f9f5780245..6386bc16dd3 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index fc13ad150ba..a1136825b1b 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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" |