r191530 - Added a comment and another test for the UT_ForIndentation option

Alexander Kornienko alexfh at google.com
Fri Sep 27 09:40:11 PDT 2013


Author: alexfh
Date: Fri Sep 27 11:40:11 2013
New Revision: 191530

URL: http://llvm.org/viewvc/llvm-project?rev=191530&view=rev
Log:
Added a comment and another test for the UT_ForIndentation option

Modified:
    cfe/trunk/lib/Format/WhitespaceManager.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/WhitespaceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/WhitespaceManager.cpp?rev=191530&r1=191529&r2=191530&view=diff
==============================================================================
--- cfe/trunk/lib/Format/WhitespaceManager.cpp (original)
+++ cfe/trunk/lib/Format/WhitespaceManager.cpp Fri Sep 27 11:40:11 2013
@@ -290,6 +290,8 @@ void WhitespaceManager::appendIndentText
   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;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=191530&r1=191529&r2=191530&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Sep 27 11:40:11 2013
@@ -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"





More information about the cfe-commits mailing list