]> granicus.if.org Git - clang/commit
[clang-format] [PR43531] clang-format damages "alternative representations" for operators
authorPaul Hoad <mydeveloperday@gmail.com>
Fri, 4 Oct 2019 14:16:59 +0000 (14:16 +0000)
committerPaul Hoad <mydeveloperday@gmail.com>
Fri, 4 Oct 2019 14:16:59 +0000 (14:16 +0000)
commit96aaa24db16a88715a6b8e92a4929e48d12f3835
tree47176d7e9c88a9d22e82091bf62a3212042e31f7
parent35019497fe483b5bf762d7ec5580585b6f50de4b
[clang-format] [PR43531] clang-format damages "alternative representations" for operators

Summary:
https://bugs.llvm.org/show_bug.cgi?id=43531

Fix for clang-format incorrectly handles "alternative operators" as described by https://en.cppreference.com/w/cpp/language/operator_alternative

compl = ~
not = !

these are unary operators, and clang-format will remove the space between them and a numeric constant

this incorrectly formats the following code

```
int a compl 5;
int a not 5;
```

into:

```
int a compl5;
int a not5;
```

The code adds FIXME unit tests for "alternative token" representations for {} [] and # as defined by the same link, which would require a more detailed change to the FormatTokenLexer

Reviewers: klimek, reuk, owenpan, mitchell-stellar, STL_MSFT

Reviewed By: mitchell-stellar

Subscribers: cfe-commits

Tags: #clang-format, #clang-tools-extra, #clang

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

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