]> granicus.if.org Git - clang/commitdiff
Added a comment and another test for the UT_ForIndentation option
authorAlexander Kornienko <alexfh@google.com>
Fri, 27 Sep 2013 16:40:11 +0000 (16:40 +0000)
committerAlexander Kornienko <alexfh@google.com>
Fri, 27 Sep 2013 16:40:11 +0000 (16:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191530 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/WhitespaceManager.cpp
unittests/Format/FormatTest.cpp

index 802145e72d852b26db03bff845d2a11d87e77b23..16d80ea429a175c11a1fcb8f00582d208669dce1 100644 (file)
@@ -290,6 +290,8 @@ void WhitespaceManager::appendIndentText(std::string &Text,
   case FormatStyle::UT_ForIndentation:
     if (WhitespaceStartColumn == 0) {
       unsigned Indentation = IndentLevel * Style.IndentWidth;
+      // This happens, e.g. when a line in a block comment is indented less than
+      // the first one.
       if (Indentation > Spaces)
         Indentation = Spaces;
       unsigned Tabs = Indentation / Style.TabWidth;
index 4c7399113d4a4a3fba33eb8106d1200025129a9f..08b5643ac0870c396c769e222e094a24f255be9d 100644 (file)
@@ -5932,7 +5932,19 @@ TEST_F(FormatTest, ConfigurableUseOfTab) {
                    "\t/*\n"
                    "\n"
                    "\t*/\n"
-                   "}", Tab));
+                   "}",
+                   Tab));
+  EXPECT_EQ("{\n"
+            "\t/*\n"
+            " asdf\n"
+            "\t*/\n"
+            "}",
+            format("{\n"
+                   "\t/*\n"
+                   " asdf\n"
+                   "\t*/\n"
+                   "}",
+                   Tab));
 
   Tab.UseTab = FormatStyle::UT_Never;
   EXPECT_EQ("/*\n"