From: Daniel Jasper Date: Sun, 2 Nov 2014 22:46:42 +0000 (+0000) Subject: clang-format: Fix false positive in lambda detection. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=932a3713130763ed82e2bb0b3dfacc8654a21af9;p=clang clang-format: Fix false positive in lambda detection. Before: delete [] a -> b; After: delete[] a->b; This fixes part of llvm.org/PR21419. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221114 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 7d54156c3b..0c8d486f0e 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -849,7 +849,8 @@ bool UnwrappedLineParser::tryToParseLambda() { // 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(); diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index c91d378dd4..cd83265106 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -4889,6 +4889,7 @@ TEST_F(FormatTest, UnderstandsNewAndDelete) { verifyFormat("auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =\n" " new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))\n" " typename aaaaaaaaaaaaaaaaaaaaaaaa();"); + verifyFormat("delete[] h->p;"); } TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {