[clang-format] Spacing in C-like casts

Hi everybody,

Here is a code sample:

It was formatted with SpaceAfterCStyleCast: true option. However, while bool was formatted, uint8_t wasn’t. Looks like a bug to me. Or is it a feature? Full config is in the attachment.

Cheers,
Oleksii

.clang-format (3.05 KB)

This is one of the cases for which the C and C++ grammars require
contextual information to parse, which is where clang-format is most likely
to make mistakes. Consider:

  int uint8_t(int); // a function, not a type
  x = (uint8_t)(123); // not a cast

However, given the relative frequency of that case and of C-style casts,
clang-format should probably be assuming that this syntax is a cast. (It's
not completely clear, though; parenthesizing the function name is an idiom
for turning off ADL, and it's possible that there are codebases that make
heavy use of that idiom.)

Is there a possibility in a foreseeable future to separate C and C++ languages, so that a proper parsing is done for each and language-specific configurations appear? There are already few grammars for Java, ObjC and even Javascript, so I make a conclusion that clang-format developers, fortunately, do not have any specific prejudice towards C, it might be just a matter of time and human resources.

Oleksii