-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Closed
Closed
Copy link
Labels
clang-formatenhancementImproving things as opposed to bug fixing, e.g. new or missing featureImproving things as opposed to bug fixing, e.g. new or missing featuregood first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contribute
Description
In clang-13, a concept definition with requires-expression will be formatted like this:
template <typename EnvT>
concept Env = requires(EnvT&& env) {
{ step(env) } -> std::convertible_to<int>;
};
But after commits in https://reviews.llvm.org/D113319, above code will be formatted to:
template <typename EnvT>
concept Env = requires (EnvT&& env) {
{ step(env) } -> std::convertible_to<int>;
};
After some investigation, it reveals that the difference was rooted in following code:
llvm-project/clang/lib/Format/ContinuationIndenter.cpp
Lines 1399 to 1400 in 24d6cc6
if (Current.is(TT_RequiresExpression)) | |
CurrentState.NestedBlockIndent = State.Column; |
It unconditionally sets the indentation to be aligned with requires
keyword. After removing it and recompile clang-format, the code is formatted as what clang-13 does:
template <typename EnvT>
concept Env = requires (EnvT&& env) {
{ step(env) } -> std::convertible_to<int>;
};
These two indentations are just different style preferences, therefore should be made configurable in .clang-format
file.
Metadata
Metadata
Assignees
Labels
clang-formatenhancementImproving things as opposed to bug fixing, e.g. new or missing featureImproving things as opposed to bug fixing, e.g. new or missing featuregood first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contribute