[PATCH] D45168: [clang-format/ObjC] Do not insert space after opening brace of ObjC dict literal

Ben Hamilton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 3 07:12:04 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL329069: [clang-format/ObjC] Do not insert space after opening brace of ObjC dict literal (authored by benhamilton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45168?vs=140634&id=140781#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45168

Files:
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/FormatTestObjC.cpp


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2480,6 +2480,9 @@
     return false;
   if (Left.is(TT_TemplateCloser) && Right.is(tok::l_square))
     return false;
+  if (Left.is(tok::l_brace) && Left.endsSequence(TT_DictLiteral, tok::at))
+    // Objective-C dictionary literal -> no space after opening brace.
+    return false;
   if (Right.is(tok::r_brace) && Right.MatchingParen &&
       Right.MatchingParen->endsSequence(TT_DictLiteral, tok::at))
     // Objective-C dictionary literal -> no space before closing brace.
Index: cfe/trunk/unittests/Format/FormatTestObjC.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp
@@ -1021,8 +1021,17 @@
                "  a12345 = @{a12345 : a12345};\n"
                "}");
   verifyFormat("int Foo() {\n"
+               "  a12345 = @{a12345 : @(a12345)};\n"
+               "}");
+  verifyFormat("int Foo() {\n"
                "  a12345 = @{(Foo *)a12345 : @(a12345)};\n"
                "}");
+  verifyFormat("int Foo() {\n"
+               "  a12345 = @{@(a12345) : a12345};\n"
+               "}");
+  verifyFormat("int Foo() {\n"
+               "  a12345 = @{@(a12345) : @YES};\n"
+               "}");
   Style.SpacesInContainerLiterals = false;
   verifyFormat("int Foo() {\n"
                "  b12345 = @{b12345: b12345};\n"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45168.140781.patch
Type: text/x-patch
Size: 1568 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180403/84a5316f/attachment-0001.bin>


More information about the cfe-commits mailing list