[cfe-commits] [PATCH] Remove bad fix.

Daniel Jasper djasper at google.com
Mon Dec 3 15:12:53 PST 2012


Hi klimek,

This removes the !DryRun check and adds a test that fails with it.  The test case is a bit hard to construct as you have to create a situation where the formatter makes a bad decision early on based on the missing stack pops. It can't directly make mistakes because the actual formatting is always done with DryRun=false.

Also fixes bad header guard naming.

http://llvm-reviews.chandlerc.com/D159

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp

Index: include/clang/Format/Format.h
===================================================================
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -15,7 +15,7 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_FORMAT_FORMAT_H_
+#ifndef LLVM_CLANG_FORMAT_FORMAT_H
 #define LLVM_CLANG_FORMAT_FORMAT_H
 
 #include "clang/Frontend/FrontendAction.h"
Index: lib/Format/Format.cpp
===================================================================
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -198,14 +198,12 @@
         State.InCtorInitializer = true;
       }
       // Top-level spaces are exempt as that mostly leads to better results.
-      if (Spaces > 0 && ParenLevel != 0 &&
-          ParenLevel < State.LastSpace.size())
+      if (Spaces > 0 && ParenLevel != 0 && ParenLevel < State.LastSpace.size())
         State.LastSpace[ParenLevel] = State.Column + Spaces;
       State.Column += Current.Tok.getLength() + Spaces;
     }
 
-    if (!DryRun &&
-        (Current.Tok.is(tok::r_paren) || Current.Tok.is(tok::r_square) ||
+    if ((Current.Tok.is(tok::r_paren) || Current.Tok.is(tok::r_square) ||
          Annotations[Index].Type == TokenAnnotation::TT_TemplateOpener)) {
       State.Indent.pop_back();
       State.LastSpace.pop_back();
Index: unittests/Format/FormatTest.cpp
===================================================================
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -256,6 +256,12 @@
   verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
                "    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
                "        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa));");
+
+  verifyFormat(
+      "aaaaaaaa(aaaaaaaaaaaaa, aaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+      "                            aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)),\n"
+      "         aaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+      "             aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)));");
 }
 
 TEST_F(FormatTest, AlignsStringLiterals) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159.1.patch
Type: text/x-patch
Size: 2125 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121203/b7bff675/attachment.bin>


More information about the cfe-commits mailing list