diff options
| author | Daniel Jasper <djasper@google.com> | 2014-12-18 12:11:01 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2014-12-18 12:11:01 +0000 |
| commit | 3a623dbd2af470264b9782b432a920a5837090dc (patch) | |
| tree | cfcd5bd89a5417d9330d8f798cb443079ecd710b | |
| parent | 07c0f04e08c840fc8bf1bfb8d5a2775b40c6e503 (diff) | |
| download | bcm5719-llvm-3a623dbd2af470264b9782b432a920a5837090dc.tar.gz bcm5719-llvm-3a623dbd2af470264b9782b432a920a5837090dc.zip | |
clang-format: Fix incorrect detection of ObjC "in" keyword.
Before:
for (auto v : in [1]) { ..
After:
for (auto v : in[1]) { ..
llvm-svn: 224513
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 3 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index deda40cab89..2e97ffffbec 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -511,7 +511,8 @@ private: parseTemplateDeclaration(); break; case tok::identifier: - if (Line.First->is(tok::kw_for) && Tok->is(Keywords.kw_in)) + if (Line.First->is(tok::kw_for) && Tok->is(Keywords.kw_in) && + Tok->Previous->isNot(tok::colon)) Tok->Type = TT_ObjCForIn; break; case tok::comma: diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 743f501b0d1..66835d74b3b 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -6781,6 +6781,7 @@ TEST_F(FormatTest, FormatObjCMethodExpr) { // Whew! verifyFormat("return in[42];"); + verifyFormat("for (auto v : in[1]) {\n}"); verifyFormat("for (id foo in [self getStuffFor:bla]) {\n" "}"); verifyFormat("[self aaaaa:MACRO(a, b:, c:)];"); |

