aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaModule.cpp
diff options
context:
space:
mode:
authorMarek Kurdej <marek.kurdej+llvm.org@gmail.com>2022-02-22 22:32:03 +0100
committerMarek Kurdej <marek.kurdej+llvm.org@gmail.com>2022-02-24 10:21:02 +0100
commitbfb4afee74c8d6e3b1d020564bfe163073f07a04 (patch)
treed3f5d7ca75a3b19a558a038825012953de15cf4f /clang/lib/Sema/SemaModule.cpp
parent56b5f001869664a1449e5e0fec677089153bf8c8 (diff)
downloadllvm-bfb4afee74c8d6e3b1d020564bfe163073f07a04.zip
llvm-bfb4afee74c8d6e3b1d020564bfe163073f07a04.tar.gz
llvm-bfb4afee74c8d6e3b1d020564bfe163073f07a04.tar.bz2
[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
Diffstat (limited to 'clang/lib/Sema/SemaModule.cpp')
0 files changed, 0 insertions, 0 deletions