summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorKrasimir Georgiev <krasimir@google.com>2019-10-18 15:21:06 +0000
committerKrasimir Georgiev <krasimir@google.com>2019-10-18 15:21:06 +0000
commiteff2a2ab2b51070133c39336c91b3f8d1c31e0c4 (patch)
tree0c580695486851f8e1abc9935cd7c0696c9714c1 /clang/lib/Format/TokenAnnotator.cpp
parent7e5d5ee873e14b7e3db0ee07fa402aca13f83a36 (diff)
downloadbcm5719-llvm-eff2a2ab2b51070133c39336c91b3f8d1c31e0c4.tar.gz
bcm5719-llvm-eff2a2ab2b51070133c39336c91b3f8d1c31e0c4.zip
[clang-format] fix regression recognizing casts in Obj-C calls
Summary: r373922 added checks for a few tokens that, following an `)` make it unlikely that the `)` is the closing paren of a cast expression. The specific check for `tok::l_square` there introduced a regression for casts of Obj-C calls, like: ``` (cast)[func arg] ``` From the tests added in r373922, I believe the `tok::l_square` case is added to capture the case where a non-cast `)` is directly followed by an attribute specifier, like: ``` int f(int x) [[noreturn]]; ``` I've specialized the code to look for such attribute specifier instead of `tok::l_square` in general. Also, I added a regression test and moved the test cases added in r373922 to an already existing place documenting other instances of historically misidentified casts. Reviewers: MyDeveloperDay Reviewed By: MyDeveloperDay Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69164 llvm-svn: 375247
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 9823a5af9c1..7aa1f378f0b 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1607,8 +1607,9 @@ private:
// Functions which end with decorations like volatile, noexcept are unlikely
// to be casts.
if (Tok.Next->isOneOf(tok::kw_noexcept, tok::kw_volatile, tok::kw_const,
- tok::kw_throw, tok::l_square, tok::arrow,
- Keywords.kw_override, Keywords.kw_final))
+ tok::kw_throw, tok::arrow, Keywords.kw_override,
+ Keywords.kw_final) ||
+ isCpp11AttributeSpecifier(*Tok.Next))
return false;
// As Java has no function types, a "(" after the ")" likely means that this
OpenPOWER on IntegriCloud