diff options
author | Daniel Jasper <djasper@google.com> | 2016-02-01 11:21:07 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2016-02-01 11:21:07 +0000 |
commit | d27df3dd3d7b4df6a47222f4cecfd727fcb279ea (patch) | |
tree | 2383c9d5c1c9311202162ab0e75bc9b744f12e43 | |
parent | e1a7b76338668c639e0611c97be4c3104224a507 (diff) | |
download | bcm5719-llvm-d27df3dd3d7b4df6a47222f4cecfd727fcb279ea.tar.gz bcm5719-llvm-d27df3dd3d7b4df6a47222f4cecfd727fcb279ea.zip |
clang-format: Fix incorrect pointer detection in lambdas in constructor
initializers.
Before:
Constructor() : member([](A *a, B * b) {}) {}
After:
Constructor() : member([](A *a, B *b) {}) {}
llvm-svn: 259353
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 4 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 1 |
2 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 6d02557dd9c..371c6a3a830 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -887,8 +887,8 @@ private: Previous && Previous->isOneOf(tok::star, tok::amp); Previous = Previous->Previous) Previous->Type = TT_PointerOrReference; - if (Line.MustBeDeclaration) - Contexts.back().IsExpression = Contexts.front().InCtorInitializer; + if (Line.MustBeDeclaration && !Contexts.front().InCtorInitializer) + Contexts.back().IsExpression = false; } else if (Current.Previous && Current.Previous->is(TT_CtorInitializerColon)) { Contexts.back().IsExpression = true; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 17db98fe79f..ad355398508 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5634,6 +5634,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyFormat("[](const decltype(*a) &value) {}"); verifyFormat("decltype(a * b) F();"); verifyFormat("#define MACRO() [](A *a) { return 1; }"); + verifyFormat("Constructor() : member([](A *a, B *b) {}) {}"); verifyIndependentOfContext("typedef void (*f)(int *a);"); verifyIndependentOfContext("int i{a * b};"); verifyIndependentOfContext("aaa && aaa->f();"); |