[clang] [clang-format] Add space after a word token (PR #92741)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Tue May 21 00:24:35 PDT 2024
owenca wrote:
> Since I am by no means an expert on Clang, a few questions arose
>
> * As Clang formats the code correctly (no code changes necessary) when instead of `xor` a different function name e.g. `xooor` is used, I wonder why `xor` is tokenized as Unary operator in the first place in C?
> * Is C and C++ using the same tokenizations?
clang-format formats all C code as C++. Since `xor` is a C++ keyword, it's lexed as `tok::caret`, which is then erroneously annotated as `TT_UnaryOperator`. This bug was uncovered by #90161.
> * How to properly distinguish between the C and C++ language in Clang Format?
clang-format can't do it properly. @mydeveloperday, @HazardyKnusperkeks, and @rymiel may know more about why we didn't add `LK_C` to the [`Language`](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#language) option.
https://github.com/llvm/llvm-project/pull/92741
More information about the cfe-commits
mailing list