Skip to content
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 not idempotent (cycles between two variants) #72662

Closed
kparzysz opened this issue Nov 17, 2023 · 1 comment · Fixed by #73886
Closed

clang-format not idempotent (cycles between two variants) #72662

kparzysz opened this issue Nov 17, 2023 · 1 comment · Fixed by #73886
Assignees

Comments

@kparzysz
Copy link
Contributor

Source cf-test.cpp:

#define SYMBOL(Name, NS, Header)                                               \
  {                                                                            \
    #NS #Name, static_cast<decltype(Symbol::NSLen)>(StringRef(#NS).size()),    \
        #Header                                                                \
  }                                                                            \
  ,
$ clang-format cf-test.cpp
#define SYMBOL(Name, NS, Header)                                               \
  {#NS #Name, static_cast<decltype(Symbol::NSLen)>(StringRef(#NS).size()),     \
   #Header},
$ clang-format cf-test.cpp | clang-format
#define SYMBOL(Name, NS, Header)                                               \
  {                                                                            \
    #NS #Name, static_cast<decltype(Symbol::NSLen)>(StringRef(#NS).size()),    \
        #Header                                                                \
  }                                                                            \
  ,
$ clang-format cf-test.cpp | clang-format | clang-format
#define SYMBOL(Name, NS, Header)                                               \
  {#NS #Name, static_cast<decltype(Symbol::NSLen)>(StringRef(#NS).size()),     \
   #Header},
@owenca
Copy link
Contributor

owenca commented Nov 29, 2023

Bisected to 063e3fe. @rymiel

@rymiel rymiel self-assigned this Nov 30, 2023
rymiel added a commit to rymiel/llvm-project that referenced this issue Nov 30, 2023
PR llvm#69473 introduced skipping PP directives when determining the brace
kind of an lbrace. However, it did so by skipping to the end of the line
when encountering a hash character. This means it also skipped to the
end of line when encountering a macro stringizing operator, which, unlike
PP directives, don't have effect until the end of line.

This led to cases where the rbrace could be completely skipped if it was
on the same line as a stringizing operator.

This patch skips hash characters if we're already in a PP directive, as
you can't define a macro inside of a macro

Fixes llvm#72662
rymiel added a commit that referenced this issue Nov 30, 2023
…3886)

PR #69473 introduced skipping PP directives when determining the brace
kind of an lbrace. However, it did so by skipping to the end of the line
when encountering a hash character. This means it also skipped to the
end of line when encountering a macro stringizing operator, which,
unlike PP directives, don't have effect until the end of line.

This led to cases where the rbrace could be completely skipped if it was
on the same line as a stringizing operator.

This patch skips hash characters if we're already in a PP directive, as
you can't define a macro inside of a macro

Fixes #72662
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants