]> granicus.if.org Git - clang/commitdiff
clang-format: [Proto] Fix "import public" after r273179.
authorDaniel Jasper <djasper@google.com>
Mon, 20 Jun 2016 20:39:53 +0000 (20:39 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 20 Jun 2016 20:39:53 +0000 (20:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273196 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/UnwrappedLineParser.cpp
unittests/Format/FormatTestProto.cpp

index 53d8c15d48d92acfc77b8522bf79276116060ff1..2fe72987bc7ce21dbecbd3f7ec77be8355f18163 100644 (file)
@@ -889,6 +889,8 @@ void UnwrappedLineParser::parseStructuralElement() {
       }
       if (Style.Language == FormatStyle::LK_Proto) {
         nextToken();
+        if (FormatTok->is(tok::kw_public))
+          nextToken();
         if (!FormatTok->is(tok::string_literal))
           return;
         nextToken();
index 68d724981ced14a4135afe0de33526626b6f1877..2580f7fb8c0387f3a31603d13e6e4d465a556591 100644 (file)
@@ -196,6 +196,12 @@ TEST_F(FormatTestProto, FormatsImports) {
                "message A {\n"
                "}");
 
+  verifyFormat("import public \"a.proto\";\n"
+               "import \"b.proto\";\n"
+               "// comment\n"
+               "message A {\n"
+               "}");
+
   // Missing semicolons should not confuse clang-format.
   verifyFormat("import \"a.proto\"\n"
                "import \"b.proto\"\n"