[all-commits] [llvm/llvm-project] eff2a2: [clang-format] fix regression recognizing casts in...

Krasimir Georgiev via All-commits all-commits at lists.llvm.org
Fri Oct 18 08:19:55 PDT 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: eff2a2ab2b51070133c39336c91b3f8d1c31e0c4
      https://github.com/llvm/llvm-project/commit/eff2a2ab2b51070133c39336c91b3f8d1c31e0c4
  Author: Krasimir Georgiev <krasimir at google.com>
  Date:   2019-10-18 (Fri, 18 Oct 2019)

  Changed paths:
    M clang/lib/Format/TokenAnnotator.cpp
    M clang/unittests/Format/FormatTest.cpp

  Log Message:
  -----------
  [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




More information about the All-commits mailing list