forked from OSchip/llvm-project
clang-format: Fix indentation of struct definitions with array init.
Before: struct { int x; int y; } points[] = { {1, 2}, {2, 3}, }; After: struct { int x; int y; } points[] = { {1, 2}, {2, 3}, }; llvm-svn: 220195
This commit is contained in:
parent
fce039240a
commit
86296e36d7
|
@ -1035,11 +1035,7 @@ static int PrecedenceArrowAndPeriod = prec::PointerToMember + 2;
|
|||
/// operator precedence.
|
||||
class ExpressionParser {
|
||||
public:
|
||||
ExpressionParser(AnnotatedLine &Line) : Current(Line.First) {
|
||||
// Skip leading "}", e.g. in "} else if (...) {".
|
||||
if (Current->is(tok::r_brace))
|
||||
next();
|
||||
}
|
||||
ExpressionParser(AnnotatedLine &Line) : Current(Line.First) {}
|
||||
|
||||
/// \brief Parse expressions with the given operatore precedence.
|
||||
void parse(int Precedence = 0) {
|
||||
|
@ -1086,7 +1082,7 @@ public:
|
|||
|
||||
// At the end of the line or when an operator with higher precedence is
|
||||
// found, insert fake parenthesis and return.
|
||||
if (!Current || Current->closesScope() ||
|
||||
if (!Current || (Current->closesScope() && Current->MatchingParen) ||
|
||||
(CurrentPrecedence != -1 && CurrentPrecedence < Precedence)) {
|
||||
if (LatestOperator) {
|
||||
LatestOperator->LastOperator = true;
|
||||
|
|
|
@ -2311,6 +2311,16 @@ TEST_F(FormatTest, NestedStaticInitializers) {
|
|||
" {kOsWin, \"Windows\"},\n"
|
||||
" {kOsLinux, \"Linux\"},\n"
|
||||
" {kOsCrOS, \"Chrome OS\"}};");
|
||||
verifyFormat(
|
||||
"struct {\n"
|
||||
" unsigned bit;\n"
|
||||
" const char *const name;\n"
|
||||
"} kBitsToOs[] = {\n"
|
||||
" {kOsMac, \"Mac\"},\n"
|
||||
" {kOsWin, \"Windows\"},\n"
|
||||
" {kOsLinux, \"Linux\"},\n"
|
||||
" {kOsCrOS, \"Chrome OS\"},\n"
|
||||
"};");
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, FormatsSmallMacroDefinitionsInSingleLine) {
|
||||
|
|
Loading…
Reference in New Issue