aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Format/Format.cpp4
-rw-r--r--unittests/Format/FormatTest.cpp7
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 0797fb8da4..299a8558b9 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -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;
}
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index df0b2962f2..a8c327a0d5 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -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