llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.94k stars 11.94k forks source link

Bad operator formatting - strange indentation #34003

Open llvmbot opened 7 years ago

llvmbot commented 7 years ago
Bugzilla Link 34655
Version trunk
OS Windows NT
Attachments Code example
Reporter LLVM Bugzilla Contributor

Extended Description

clang-format config:

Language: Cpp
AlignOperands: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakStringLiterals: true
ColumnLimit: 120
ContinuationIndentWidth: 4
IndentWidth: 4
SpaceBeforeAssignmentOperators: true
TabWidth: 4
UseTab: Never

// BEFORE:

#include <cstdint>

typedef uint8_t SomeType;

SomeType someVar;
SomeType someOtherVar;
uint64_t someYetAnotherVar;
int64_t someDiff;

int main()
{
    SomeType first = static_cast<SomeType>((((static_cast<int64_t>(someVar) + static_cast<int64_t>(someOtherVar))
        * static_cast<int64_t>(someYetAnotherVar) + someDiff) / static_cast<int64_t>(someYetAnotherVar))
        % static_cast<int64_t>(someOtherVar));

    return 0;
}

// AFTER:

#include <cstdint>

typedef uint8_t SomeType;

SomeType someVar;
SomeType someOtherVar;
uint64_t someYetAnotherVar;
int64_t someDiff;

int main() {
    SomeType first = static_cast<SomeType>((((static_cast<int64_t>(someVar) + static_cast<int64_t>(someOtherVar)) *
                                                 static_cast<int64_t>(someYetAnotherVar) +
                                             someDiff) /
                                            static_cast<int64_t>(someYetAnotherVar)) %
                                           static_cast<int64_t>(someOtherVar));

    return 0;
}

Why the subsequent lines are so strangely indented?

llvmbot commented 7 years ago

CodeExample2 Added yet another example of the strange indentation.

llvmbot commented 7 years ago

Please copy the examples to an editor or find the attachment to see how the indentation looks like.

Here the code excerpts were wrapped by the bugtracking web page.