8000 clang-format always aligns stream operator << with spaces · Issue #59797 · llvm/llvm-project · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000
clang-format always aligns stream operator << with spaces #59797
Open
@knarfS

Description

@knarfS

Description

The UseTab option is set to Always, but clang-format is using spaces to align the << operator in continued lines. This behavior occurs even when all the Align* options are set to false. Also BreakBeforeBinaryOperators has no influence on the alignment (or even breaking before/after) of the stream operator <<.

The unwanted leading spaces then trigger other format checkers like EditorConfig (which is set to indent_style·=·tab)

Steps to reproduce

  1. Create a minimal .clang-format file with the following configuration:
---
AlignAfterOpenBracket: DontAlign
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: DontAlign
AlignTrailingComments: false
BreakBeforeBinaryOperators: NonAssignment
ColumnLimit: 80
ContinuationIndentWidth: 4
IndentWidth: 4
TabWidth: 4
UseTab: Always
...
  1. Use clang-format to format the following code:
void someFunction() {
	std::cout << someVariable << "Some random string for std::cout " << someOtherVariable << ", "
		<< andAnotherOne << andOneMore << ", some final text.";
}

Expected behavior

The << operators in the continued lines should not be aligned and only be indented with tab characters, not with spaces:

void someFunction() {
	std::cout << someVariable << "Some random string for std::cout "
		<< someOtherVariable << ", " << andAnotherOne << andOneMore
		<< ", some final text.";
}

Actual behavior

The << operators in the continued lines are indented with three tabs and with two additional spaces for alignment:

void someFunction() {
	std::cout << someVariable << "Some random string for std::cout "
			  << someOtherVariable << ", " << andAnotherOne << andOneMore
			  << ", some final text.";
}

Environment

  • clang-format version: Debian clang-format version 14.0.6
  • Operating system: Debian Testing x86_64

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

      0