================
@@ -4842,7 +4842,7 @@ bool TokenAnnotator::spaceRequiredBefore(const
AnnotatedLine &Line,
return true;
}
if (Left.is(TT_UnaryOperator)) {
- if (Right.isNot(tok::l_paren)) {
+ if (!Right.isOneOf(tok::r_paren, tok::l_paren, tok::exclaim)) {
----------------
ilya-biryukov wrote:
I have used `!` merely as an example, I feel that we should probably not add
space for almost all tokens:
```cpp
#define str(X) #X
#define v(X) str(foo##X)
char *x = v(not;);
char *y = v(not+);
```
The only exception I see are identifiers and numeric literals (as they will
combine the tokens together):
```cpp
v(not x)
v(not 1)
v(not 123.f)
```
Should this condition be something like `if (Right.isOneOf(tok::ident, /*...
numeric literals*/))`?
Or will this cause us to not add spaces in undesired places?
If we can avoid those spaces for only a limited set of tokens, I would probably
limit this to `tok::lparen` and `tok::rparen`, the rest seems much less likely.
https://github.com/llvm/llvm-project/pull/78176
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits