summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2016-11-01 06:23:14 +0000
committerDaniel Jasper <djasper@google.com>2016-11-01 06:23:14 +0000
commitd0d27aa59b0e7e6851d71da24835597658ccaa8a (patch)
treec41857b6bb7be274a29c30eaf9fec18556c3ff8a
parentb559b43802d040888f5cf4931d05fc12a18c8e81 (diff)
downloadbcm5719-llvm-d0d27aa59b0e7e6851d71da24835597658ccaa8a.tar.gz
bcm5719-llvm-d0d27aa59b0e7e6851d71da24835597658ccaa8a.zip
clang-format: Fix incorrect pointer detection.
Before: void f() { f(float{1}, a *a); } After: void f() { f(float{1}, a * a); } llvm-svn: 285673
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp5
-rw-r--r--clang/unittests/Format/FormatTest.cpp1
2 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 1a3faad6e28..d010efab3e5 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -273,8 +273,9 @@ private:
!CurrentToken->Next->HasUnescapedNewline &&
!CurrentToken->Next->isTrailingComment())
HasMultipleParametersOnALine = true;
- if (CurrentToken->isOneOf(tok::kw_const, tok::kw_auto) ||
- CurrentToken->isSimpleTypeSpecifier())
+ if ((CurrentToken->Previous->isOneOf(tok::kw_const, tok::kw_auto) ||
+ CurrentToken->Previous->isSimpleTypeSpecifier()) &&
+ !CurrentToken->is(tok::l_brace))
Contexts.back().IsExpression = false;
if (CurrentToken->isOneOf(tok::semi, tok::colon))
MightBeObjCForRangeLoop = false;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 8fe835e5793..6ab4a746290 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5870,6 +5870,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
verifyIndependentOfContext("MACRO(auto *a);");
verifyIndependentOfContext("MACRO(const A *a);");
verifyIndependentOfContext("MACRO('0' <= c && c <= '9');");
+ verifyFormat("void f() { f(float{1}, a * a); }");
// FIXME: Is there a way to make this work?
// verifyIndependentOfContext("MACRO(A *a);");
OpenPOWER on IntegriCloud