r181318 - Correctly recognize dereference after 'delete'.
Daniel Jasper
djasper at google.com
Tue May 7 07:17:18 PDT 2013
Author: djasper
Date: Tue May 7 09:17:18 2013
New Revision: 181318
URL: http://llvm.org/viewvc/llvm-project?rev=181318&view=rev
Log:
Correctly recognize dereference after 'delete'.
With certain styles:
Before: delete* x;
After: delete *x;
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=181318&r1=181317&r2=181318&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue May 7 09:17:18 2013
@@ -664,8 +664,8 @@ private:
}
/// \brief Return the type of the given token assuming it is * or &.
- TokenType
- determineStarAmpUsage(const AnnotatedToken &Tok, bool IsExpression) {
+ TokenType determineStarAmpUsage(const AnnotatedToken &Tok,
+ bool IsExpression) {
const AnnotatedToken *PrevToken = Tok.getPreviousNoneComment();
if (PrevToken == NULL)
return TT_UnaryOperator;
@@ -679,7 +679,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::equal, tok::kw_delete) ||
PrevToken->Type == TT_BinaryOperator ||
PrevToken->Type == TT_UnaryOperator || PrevToken->Type == TT_CastRParen)
return TT_UnaryOperator;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=181318&r1=181317&r2=181318&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue May 7 09:17:18 2013
@@ -2598,6 +2598,9 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
verifyIndependentOfContext("A = new SomeType *[Length]();");
verifyGoogleFormat("A = new SomeType* [Length]();");
verifyGoogleFormat("A = new SomeType* [Length];");
+ FormatStyle PointerLeft = getLLVMStyle();
+ PointerLeft.PointerBindsToType = true;
+ verifyFormat("delete *x;", PointerLeft);
}
TEST_F(FormatTest, UnderstandsEllipsis) {
More information about the cfe-commits
mailing list