summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-05-05 12:36:29 +0000
committerDaniel Jasper <djasper@google.com>2014-05-05 12:36:29 +0000
commit0e6c51c889bcc2088613b05ae2ca2acb64dfedbf (patch)
tree1d70b171e8dff3562c437635a991bf04911fe4d5
parent7721eb3f9d7bea88f138b2779b92a4ce04eab6da (diff)
downloadbcm5719-llvm-0e6c51c889bcc2088613b05ae2ca2acb64dfedbf.tar.gz
bcm5719-llvm-0e6c51c889bcc2088613b05ae2ca2acb64dfedbf.zip
clang-format: Improve understanding of decltype.
Before: SomeFunction([](decltype(x), A * a) {}); After: SomeFunction([](decltype(x), A *a) {}); llvm-svn: 207961
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp3
-rw-r--r--clang/unittests/Format/FormatTest.cpp3
2 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 843d8777188..65c0cabffc1 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -692,7 +692,8 @@ private:
} else if (Current.isOneOf(tok::kw_return, tok::kw_throw)) {
Contexts.back().IsExpression = true;
} else if (Current.is(tok::l_paren) && !Line.MustBeDeclaration &&
- !Line.InPPDirective) {
+ !Line.InPPDirective && Current.Previous &&
+ Current.Previous->isNot(tok::kw_decltype)) {
bool ParametersOfFunctionType =
Current.Previous && Current.Previous->is(tok::r_paren) &&
Current.Previous->MatchingParen &&
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 1380dd85a48..7db87cb3ce5 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -8432,6 +8432,9 @@ TEST_F(FormatTest, FormatsLambdas) {
verifyFormat("SomeFunction([]() { // A cool function...\n"
" return 43;\n"
"});");
+ verifyFormat("void f() {\n"
+ " SomeFunction([](decltype(x), A *a) {});\n"
+ "}");
// Lambdas with return types.
verifyFormat("int c = []() -> int { return 2; }();\n");
OpenPOWER on IntegriCloud