From 3d5a7d6b65ab7e19cd84e3041a1b663407dc61d8 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 20 Jun 2016 18:20:38 +0000 Subject: clang-format: [Proto] Don't do bad things if imports are missing ;. llvm-svn: 273179 --- clang/lib/Format/UnwrappedLineParser.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'clang/lib/Format') diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 18df7576ca2..53d8c15d48d 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -882,10 +882,21 @@ void UnwrappedLineParser::parseStructuralElement() { /*MunchSemi=*/false); return; } - if (Style.Language == FormatStyle::LK_JavaScript && - FormatTok->is(Keywords.kw_import)) { - parseJavaScriptEs6ImportExport(); - return; + if (FormatTok->is(Keywords.kw_import)) { + if (Style.Language == FormatStyle::LK_JavaScript) { + parseJavaScriptEs6ImportExport(); + return; + } + if (Style.Language == FormatStyle::LK_Proto) { + nextToken(); + if (!FormatTok->is(tok::string_literal)) + return; + nextToken(); + if (FormatTok->is(tok::semi)) + nextToken(); + addUnwrappedLine(); + return; + } } if (FormatTok->isOneOf(Keywords.kw_signals, Keywords.kw_qsignals, Keywords.kw_slots, Keywords.kw_qslots)) { -- cgit v1.2.3