]> granicus.if.org Git - clang/commit
[clang-format] Fix PR30527: Regression when clang-format insert spaces in [] when...
authorNico Weber <nicolasweber@gmx.de>
Thu, 10 Nov 2016 21:49:25 +0000 (21:49 +0000)
committerNico Weber <nicolasweber@gmx.de>
Thu, 10 Nov 2016 21:49:25 +0000 (21:49 +0000)
commite11aa0167601ab30cf671f25d69cd1c9ff553fb7
treee1939bec575f2cad2e0b0432be4df7cc75b6a481
parent557c8a817a53a540a03ed118ddf6d9a9cd8d6c0c
[clang-format] Fix PR30527: Regression when clang-format insert spaces in [] when in template

Actual regression was introduced in r272668. This revision fixes JS script, but
also regress Cpp case. It manifests with spaces added when template is followed
with array. Bug 30527 mentions case of array as a nested template type
(foo<bar<baz>[]>). Fix is to detect such case and to prevent treating it as
array initialization, but as a subscript case. However, before r272668, this
case was treated simple because we were detecting it as a StartsObjCMethodExpr.
Same was true for other similar case - array of templates (foo<int>[]). This
patch tries to address two problems: 1) fixing regression 2) making sure both
cases (array as a nested type, array of templates) which were entering
StartsObjCMethodExpr branch are handled now appropriately.

https://reviews.llvm.org/D26163
Patch from Branko Kokanovic <branko@kokanovic.org>!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286507 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp