r216724 - clang-format: Fix unary operator detection in corner case.
Daniel Jasper
djasper at google.com
Fri Aug 29 05:54:38 PDT 2014
Author: djasper
Date: Fri Aug 29 07:54:38 2014
New Revision: 216724
URL: http://llvm.org/viewvc/llvm-project?rev=216724&view=rev
Log:
clang-format: Fix unary operator detection in corner case.
Before:
decltype(* ::std::declval<const T &>()) void F();
After:
decltype(*::std::declval<const T &>()) void F();
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=216724&r1=216723&r2=216724&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Aug 29 07:54:38 2014
@@ -925,8 +925,7 @@ private:
if (!NextToken || NextToken->is(tok::l_brace))
return TT_Unknown;
- if (PrevToken->is(tok::coloncolon) ||
- (PrevToken->is(tok::l_paren) && !IsExpression))
+ if (PrevToken->is(tok::coloncolon))
return TT_PointerOrReference;
if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=216724&r1=216723&r2=216724&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Aug 29 07:54:38 2014
@@ -4931,6 +4931,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
verifyFormat("vector<a * b> v;");
verifyFormat("foo<b && false>();");
verifyFormat("foo<b & 1>();");
+ verifyFormat("decltype(*::std::declval<const T &>()) void F();");
verifyIndependentOfContext("MACRO(int *i);");
verifyIndependentOfContext("MACRO(auto *a);");
More information about the cfe-commits
mailing list