r185699 - Fix formatting for allocation of new pointer variables.
Daniel Jasper
djasper at google.com
Fri Jul 5 06:30:40 PDT 2013
Author: djasper
Date: Fri Jul 5 08:30:40 2013
New Revision: 185699
URL: http://llvm.org/viewvc/llvm-project?rev=185699&view=rev
Log:
Fix formatting for allocation of new pointer variables.
Before:
T **t = new T * ;
T **q = new T * ();
After:
T **t = new T *;
T **q = new T *();
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=185699&r1=185698&r2=185699&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Jul 5 08:30:40 2013
@@ -591,7 +591,8 @@ private:
NameFound = true;
} else if (Current.isOneOf(tok::star, tok::amp, tok::ampamp)) {
Current.Type =
- determineStarAmpUsage(Current, Contexts.back().IsExpression);
+ determineStarAmpUsage(Current, Contexts.back().CanBeExpression &&
+ Contexts.back().IsExpression);
} else if (Current.isOneOf(tok::minus, tok::plus, tok::caret)) {
Current.Type = determinePlusMinusCaretUsage(Current);
} else if (Current.isOneOf(tok::minusminus, tok::plusplus)) {
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=185699&r1=185698&r2=185699&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Jul 5 08:30:40 2013
@@ -3378,8 +3378,12 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
verifyIndependentOfContext("A = new SomeType *[Length];");
verifyIndependentOfContext("A = new SomeType *[Length]();");
+ verifyIndependentOfContext("T **t = new T *;");
+ verifyIndependentOfContext("T **t = new T *();");
verifyGoogleFormat("A = new SomeType* [Length]();");
verifyGoogleFormat("A = new SomeType* [Length];");
+ verifyGoogleFormat("T** t = new T*;");
+ verifyGoogleFormat("T** t = new T*();");
FormatStyle PointerLeft = getLLVMStyle();
PointerLeft.PointerBindsToType = true;
More information about the cfe-commits
mailing list