diff options
author | Daniel Jasper <djasper@google.com> | 2014-01-22 17:01:47 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-01-22 17:01:47 +0000 |
commit | 6b70ec0d4605be6901c254510698517e42e42cdd (patch) | |
tree | a90bcdb9c7dbfcf1756db11395868fe469ca22b3 | |
parent | b6082a3d44c85bcf6ee46fb75ab3ce4a6e780f68 (diff) | |
download | bcm5719-llvm-6b70ec0d4605be6901c254510698517e42e42cdd.tar.gz bcm5719-llvm-6b70ec0d4605be6901c254510698517e42e42cdd.zip |
clang-format: Fix incorrect lambda recognition.
Before:
std::unique_ptr<int[]> foo() {}
After:
std::unique_ptr<int []> foo() {}
Also, the formatting could go severely wrong after such a function
before.
llvm-svn: 199817
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 3 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index d5423d1283d..6e18ad352af 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -753,7 +753,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) || + Line->Tokens.back().Tok->isSimpleTypeSpecifier())) { nextToken(); return false; } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index a029176eefa..7b3ea6e2f81 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -7889,6 +7889,7 @@ TEST_F(FormatTest, FormatsLambdas) { verifyFormat("constexpr char hello[]{ \"hello\" };"); verifyFormat("double &operator[](int i) { return 0; }\n" "int i;"); + verifyFormat("std::unique_ptr<int[]> foo() {}"); } TEST_F(FormatTest, FormatsBlocks) { |