[PATCH] D43294: [clang-format] Recognize percents as format specifiers in protos
    Krasimir Georgiev via Phabricator via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Wed Feb 14 11:50:01 PST 2018
    
    
  
This revision was automatically updated to reflect the committed changes.
Closed by commit rC325159: [clang-format] Recognize percents as format specifiers in protos (authored by krasimir, committed by ).
Changed prior to commit:
  https://reviews.llvm.org/D43294?vs=134232&id=134286#toc
Repository:
  rC Clang
https://reviews.llvm.org/D43294
Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestProto.cpp
  unittests/Format/FormatTestTextProto.cpp
Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2425,6 +2425,9 @@
     if (Left.MatchingParen && Left.MatchingParen->is(TT_ProtoExtensionLSquare) &&
         Right.isOneOf(tok::l_brace, tok::less))
       return !Style.Cpp11BracedListStyle;
+    // A percent is probably part of a formatting specification, such as %lld.
+    if (Left.is(tok::percent))
+      return false;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
     if (Left.is(TT_JsFatArrow))
       return true;
Index: unittests/Format/FormatTestTextProto.cpp
===================================================================
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -386,5 +386,9 @@
                "  }\n"
                "}");
 }
+
+TEST_F(FormatTestTextProto, NoSpaceAfterPercent) {
+  verifyFormat("key: %d");
+}
 } // end namespace tooling
 } // end namespace clang
Index: unittests/Format/FormatTestProto.cpp
===================================================================
--- unittests/Format/FormatTestProto.cpp
+++ unittests/Format/FormatTestProto.cpp
@@ -432,5 +432,11 @@
                "};");
 }
 
+TEST_F(FormatTestProto, NoSpaceAfterPercent) {
+  verifyFormat("option (MyProto.options) = {\n"
+               "  key: %lld\n"
+               "};");
+}
+
 } // end namespace tooling
 } // end namespace clang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43294.134286.patch
Type: text/x-patch
Size: 1486 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180214/986549cf/attachment.bin>
    
    
More information about the cfe-commits
mailing list