r221114 - clang-format: Fix false positive in lambda detection.
Daniel Jasper
djasper at google.com
Sun Nov 2 14:46:42 PST 2014
Author: djasper
Date: Sun Nov 2 16:46:42 2014
New Revision: 221114
URL: http://llvm.org/viewvc/llvm-project?rev=221114&view=rev
Log:
clang-format: Fix false positive in lambda detection.
Before:
delete [] a -> b;
After:
delete[] a->b;
This fixes part of llvm.org/PR21419.
Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=221114&r1=221113&r2=221114&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Sun Nov 2 16:46:42 2014
@@ -849,7 +849,8 @@ bool UnwrappedLineParser::tryToParseLamb
// FIXME: This is a dirty way to access the previous token. Find a better
// solution.
if (!Line->Tokens.empty() &&
- (Line->Tokens.back().Tok->isOneOf(tok::identifier, tok::kw_operator) ||
+ (Line->Tokens.back().Tok->isOneOf(tok::identifier, tok::kw_operator,
+ tok::kw_new, tok::kw_delete) ||
Line->Tokens.back().Tok->closesScope() ||
Line->Tokens.back().Tok->isSimpleTypeSpecifier())) {
nextToken();
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=221114&r1=221113&r2=221114&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Sun Nov 2 16:46:42 2014
@@ -4889,6 +4889,7 @@ TEST_F(FormatTest, UnderstandsNewAndDele
verifyFormat("auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =\n"
" new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))\n"
" typename aaaaaaaaaaaaaaaaaaaaaaaa();");
+ verifyFormat("delete[] h->p;");
}
TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
More information about the cfe-commits
mailing list