Fix indentation-detection at indent level 0.

This correctly formats:
  {
    a;
  }
where { is incorrectly indented by 2, but is at level 0, when
reformatting only 'a;'.

llvm-svn: 174737
This commit is contained in:
Manuel Klimek 2013-02-08 19:53:32 +00:00
parent ca3ed7230d
commit d076dcd54f
2 changed files with 8 additions and 3 deletions

View File

@ -977,10 +977,10 @@ private:
/// that level is unknown.
unsigned GetIndent(const std::vector<int> IndentForLevel,
unsigned Level) {
if (Level == 0)
return 0;
if (IndentForLevel[Level] != -1)
return IndentForLevel[Level];
if (Level == 0)
return 0;
return GetIndent(IndentForLevel, Level - 1) + 2;
}

View File

@ -2593,7 +2593,12 @@ TEST_F(FormatTest, ReformatRegionAdjustsIndent) {
" b;\n"
"}\n"
"}", 22, 2, getLLVMStyle()));
}
EXPECT_EQ(" {\n"
" a;\n"
" }", format(" {\n"
"a;\n"
" }", 4, 2, getLLVMStyle()));
}
} // end namespace tooling
} // end namespace clang