[clang-format] Avoid inserting space after C++ casts.
Fixes https://github.com/llvm/llvm-project/issues/53876. This is a solution for standard C++ casts: const_cast, dynamic_cast, reinterpret_cast, static_cast. A general approach handling all possible casts is not possible without semantic information. Consider the code: ``` static_cast<T>(*function_pointer_variable)(arguments); ``` vs. ``` some_return_type<T> (*function_pointer_variable)(parameters); // Later used as: function_pointer_variable = &some_function; return function_pointer_variable(args); ``` In the latter case, it's not a cast but a variable declaration of a pointer to function. Without knowing what `some_return_type<T>` is (and clang-format does not know it), it's hard to distinguish between the two cases. Theoretically, one could check whether "parameters" are types (not a cast) and "arguments" are value/expressions (a cast), but that might be inefficient (needs lots of lookahead). Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan Differential Revision: https://reviews.llvm.org/D120140
Loading
Please sign in to comment