summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2016-06-20 18:20:38 +0000
committerDaniel Jasper <djasper@google.com>2016-06-20 18:20:38 +0000
commit3d5a7d6b65ab7e19cd84e3041a1b663407dc61d8 (patch)
treeb70af72774c66f09d71a18982136a3244a2b15e2 /clang/lib/Format
parent4deb4ed21eda7d5e4fc3371a014249a36d7787b2 (diff)
downloadbcm5719-llvm-3d5a7d6b65ab7e19cd84e3041a1b663407dc61d8.tar.gz
bcm5719-llvm-3d5a7d6b65ab7e19cd84e3041a1b663407dc61d8.zip
clang-format: [Proto] Don't do bad things if imports are missing ;.
llvm-svn: 273179
Diffstat (limited to 'clang/lib/Format')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp19
1 files changed, 15 insertions, 4 deletions
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)) {
OpenPOWER on IntegriCloud