mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-29 16:41:27 +00:00
clang-format: Fix selective indentaiton in nested blocks.
Buggy case: someFunction( [] { // comment int i; // invoke formatting here. }, // force line break aaa); llvm-svn: 236091
This commit is contained in:
parent
fda237d09f
commit
eb45cb7cf9
@ -461,7 +461,9 @@ UnwrappedLineFormatter::format(const SmallVectorImpl<AnnotatedLine *> &Lines,
|
||||
|
||||
if (static_cast<int>(LevelIndent) - Offset >= 0)
|
||||
LevelIndent -= Offset;
|
||||
if (Tok->isNot(tok::comment) && !TheLine.InPPDirective)
|
||||
if ((Tok->isNot(tok::comment) ||
|
||||
IndentForLevel[TheLine.Level] == -1) &&
|
||||
!TheLine.InPPDirective)
|
||||
IndentForLevel[TheLine.Level] = LevelIndent;
|
||||
} else if (!DryRun) {
|
||||
Whitespaces->addUntouchableToken(*Tok, TheLine.InPPDirective);
|
||||
|
@ -3262,6 +3262,19 @@ TEST_F(FormatTest, IndividualStatementsOfNestedBlocks) {
|
||||
" int a; //\n"
|
||||
"});",
|
||||
0, 0, getLLVMStyle()));
|
||||
EXPECT_EQ("someFunction(\n"
|
||||
" [] {\n"
|
||||
" // Only with this comment.\n"
|
||||
" int i; // invoke formatting here.\n"
|
||||
" }, // force line break\n"
|
||||
" aaa);",
|
||||
format("someFunction(\n"
|
||||
" [] {\n"
|
||||
" // Only with this comment.\n"
|
||||
" int i; // invoke formatting here.\n"
|
||||
" }, // force line break\n"
|
||||
" aaa);",
|
||||
63, 1, getLLVMStyle()));
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, PutEmptyBlocksIntoOneLine) {
|
||||
|
Loading…
Reference in New Issue
Block a user