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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to