diff options
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTestProto.cpp | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 53d8c15d48d..2fe72987bc7 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/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/clang/unittests/Format/FormatTestProto.cpp b/clang/unittests/Format/FormatTestProto.cpp index 68d724981ce..2580f7fb8c0 100644 --- a/clang/unittests/Format/FormatTestProto.cpp +++ b/clang/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" |