[clang] [clang-format] adds a space after not inside macros (PR #78176)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 22 02:18:32 PST 2024
================
@@ -4842,19 +4842,19 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
return true;
}
if (Left.is(TT_UnaryOperator)) {
- if (Right.isNot(tok::l_paren)) {
+ if (Right.isOneOf(tok::identifier, tok::numeric_constant)) {
// The alternative operators for ~ and ! are "compl" and "not".
// If they are used instead, we do not want to combine them with
// the token to the right, unless that is a left paren.
if (Left.is(tok::exclaim) && Left.TokenText == "not")
return true;
if (Left.is(tok::tilde) && Left.TokenText == "compl")
return true;
- // Lambda captures allow for a lone &, so "&]" needs to be properly
- // handled.
- if (Left.is(tok::amp) && Right.is(tok::r_square))
- return Style.SpacesInSquareBrackets;
}
+ // Lambda captures allow for a lone &, so "&]" needs to be properly
+ // handled.
+ if (Left.is(tok::amp) && Right.is(tok::r_square))
+ return Style.SpacesInSquareBrackets;
return (Style.SpaceAfterLogicalNot && Left.is(tok::exclaim)) ||
Right.is(TT_BinaryOperator);
----------------
owenca wrote:
```suggestion
return Style.SpaceAfterLogicalNot && Left.is(tok::exclaim);
```
Would this suffice?
https://github.com/llvm/llvm-project/pull/78176
More information about the cfe-commits
mailing list