-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clang-format adds a space after not
inside macros
#78166
Comments
@llvm/issue-subscribers-clang-format Author: Ilya Biryukov (ilya-biryukov)
Expected formatting:
```cpp
#define ASSEMBLER_INSTRUCTION_LIST(V) \
V(and) \
V(not) \
V(other)
```
Actual formatting: #define ASSEMBLER_INSTRUCTION_LIST(V) \
V(and) \
V(not ) \
V(other) This can even change the meaning of some code in rare circumstances: #define ASSEMBLER_INSTRUCTION_LIST(V) \
V(and) \
V(not !) /* was not! before formatting*/ \
V(other)
#define STRINGIFY(X) #X
const char* foo = ASSEMBLER_INSTRUCTION_LIST(STRINGIFY);
/* foo was "andnot!other" before formatting
and is "andnot !other" after formatting */ |
Actually, not sure if this is invalid-code-generation, I think this is why the whitespace senitive macros option exist (not sure what exactly the policy is, someone else feel free to remove the tag) |
Space before the |
S=1 for |
its comes down to this piece of code if (Left.is(TT_UnaryOperator)) {
if (Right.isNot(tok::l_paren)) {
// 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;
}
return (Style.SpaceAfterLogicalNot && Left.is(tok::exclaim)) ||
Right.is(TT_BinaryOperator); |
its purpose was to prevent this failure in the test
becoming:
I think we can probably resolve this by adding extra logic |
would fix this use case |
Friendly ping: Is there something blocking your proposed fix in
|
@danleh check out the discussion in #78176, there's no final conclusion there yet (although I think everyone agrees there should not be a space before As for the codegen issues, |
Expected formatting:
Actual formatting:
This can even change the meaning of some code in rare circumstances:
The text was updated successfully, but these errors were encountered: