[PATCH] D54288: Fix ClangFormat issue of recognizing ObjC subscript as C++ attributes when message target is a result of a C-style method.
Yan Zhang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 8 18:49:56 PST 2018
Wizard updated this revision to Diff 173258.
Wizard added a comment.
remove blank lines
Repository:
rC Clang
https://reviews.llvm.org/D54288
Files:
lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp
Index: unittests/Format/FormatTest.cpp
===================================================================
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -6472,6 +6472,8 @@
// Make sure we do not mistake attributes for array subscripts.
verifyFormat("int a() {}\n"
"[[unused]] int b() {}\n");
+ verifyFormat("NSArray *arr;\n"
+ "arr[[Foo() bar]];");
// On the other hand, we still need to correctly find array subscripts.
verifyFormat("int a = std::vector<int>{1, 2, 3}[0];");
Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -366,7 +366,8 @@
// specifier parameter, although this is technically valid:
// [[foo(:)]]
if (AttrTok->is(tok::colon) ||
- AttrTok->startsSequence(tok::identifier, tok::identifier))
+ AttrTok->startsSequence(tok::identifier, tok::identifier) ||
+ AttrTok->startsSequence(tok::r_paren, tok::identifier))
return false;
if (AttrTok->is(tok::ellipsis))
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54288.173258.patch
Type: text/x-patch
Size: 1163 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181109/d23dbbb8/attachment.bin>
More information about the cfe-commits
mailing list