From: Daniel Jasper Date: Mon, 20 Jun 2016 20:39:53 +0000 (+0000) Subject: clang-format: [Proto] Fix "import public" after r273179. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9d5d990e4ddcc72fffc363d8bde4f8fcd868f0e3;p=clang clang-format: [Proto] Fix "import public" after r273179. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273196 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 53d8c15d48..2fe72987bc 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -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(); diff --git a/unittests/Format/FormatTestProto.cpp b/unittests/Format/FormatTestProto.cpp index 68d724981c..2580f7fb8c 100644 --- a/unittests/Format/FormatTestProto.cpp +++ b/unittests/Format/FormatTestProto.cpp @@ -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"