Skip to content

clang-format adds a space after not inside macros #78166

@ilya-biryukov

Description

@ilya-biryukov

Expected formatting:

#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 */

Metadata

Metadata

Labels

clang-formatinvalid-code-generationTool (e.g. clang-format) produced invalid code that no longer compiles

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions