Skip to content

[clang-format]: obey BlockIndent for templatesΒ #55339

@igagis

Description

@igagis

to reproduce

.clang-format

AlignAfterOpenBracket: BlockIndent
AllowAllArgumentsOnNextLine: 'false'
AllowAllParametersOfDeclarationOnNextLine: 'false'
BinPackArguments: 'false'
BinPackParameters: 'false'
ColumnLimit: '120'
ContinuationIndentWidth: '1'
IndentWidth: '1'
Language: Cpp
Standard: Cpp11
TabWidth: '1'
UseCRLF: 'false'
UseTab: ForContinuationAndIndentation

main.cpp:

void function(int asdfasdfsdhgfjhksdgfjkhsd, int sdlfsdkljahgdfklsjhgdf, int sadlkghjasdlkghjfd, int sadlkghjasdlkghjfd, int sadlkghjasdlkghjfd, int sadlkghjasdlkghjfd);

typedef typename std::conditional<
func_one_arg,typename type_or_void<std::invoke_result<F, func_arg_type>>::type,
typename type_or_void<std::invoke_result<F, func_arg_type, size_t>>::type
>::type func_return_type;

expected result

void function(
	int asdfasdfsdhgfjhksdgfjkhsd,
	int sdlfsdkljahgdfklsjhgdf,
	int sadlkghjasdlkghjfd,
	int sadlkghjasdlkghjfd,
	int sadlkghjasdlkghjfd,
	int sadlkghjasdlkghjfd
);

typedef typename std::conditional<
	func_one_arg,
	typename type_or_void<std::invoke_result<F, func_arg_type>>::type,
	typename type_or_void<std::invoke_result<F, func_arg_type, size_t>>::type
>::type func_return_type;

actual result

void function(
	int asdfasdfsdhgfjhksdgfjkhsd,
	int sdlfsdkljahgdfklsjhgdf,
	int sadlkghjasdlkghjfd,
	int sadlkghjasdlkghjfd,
	int sadlkghjasdlkghjfd,
	int sadlkghjasdlkghjfd
);

typedef typename std::conditional<
	func_one_arg,
	typename type_or_void<std::invoke_result<F, func_arg_type>>::type,
	typename type_or_void<std::invoke_result<F, func_arg_type, size_t>>::type>::type func_return_type;

As one can see, closing ) for function is moved to a new line, but closing > for template is not moved to the new line.

version

$ clang-format-14 --version
Debian clang-format version 14.0.1-++20220426012052+0e27d08cdeb3-1~exp1~20220426132142.127

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions