]> granicus.if.org Git - clang/commit
[clang-format] Don't detect call to ObjC class method as C++11 attribute specifier
authorBen Hamilton <benhamilton@google.com>
Tue, 16 Jul 2019 21:29:40 +0000 (21:29 +0000)
committerBen Hamilton <benhamilton@google.com>
Tue, 16 Jul 2019 21:29:40 +0000 (21:29 +0000)
commit34ac8add980e2e9b0a30ef72d8003a039b40757e
tree4cc1461380c4203615f700a371eff3ddccb3007b
parent3a3b332ab57891b8699a270019f8ebbf29df5b2e
[clang-format] Don't detect call to ObjC class method as C++11 attribute specifier

Summary:
Previously, clang-format detected something like the following as a C++11 attribute specifier.

  @[[NSArray class]]

instead of an array with an Objective-C method call inside. In general, when the attribute specifier checking runs, if it sees 2 identifiers in a row, it decides that the square brackets represent an Objective-C method call. However, here, `class` is tokenized as a keyword instead of an identifier, so this check fails.

To fix this, the attribute specifier first checks whether the first square bracket has an "@" before it. If it does, then that square bracket is not the start of a attribute specifier because it is an Objective-C array literal. (The assumption is that @[[.*]] is not valid C/C++.)

Contributed by rkgibson2.

Reviewers: benhamilton

Reviewed By: benhamilton

Subscribers: aaron.ballman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64632

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