summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp5
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp10
2 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 84e06d05c73..370cf7afa33 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1255,10 +1255,13 @@ void UnwrappedLineParser::tryToParseJSFunction() {
if (FormatTok->is(tok::l_brace))
tryToParseBracedList();
else
- while (FormatTok->isNot(tok::l_brace) && !eof())
+ while (!FormatTok->isOneOf(tok::l_brace, tok::semi) && !eof())
nextToken();
}
+ if (FormatTok->is(tok::semi))
+ return;
+
parseChildBlock();
}
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 6f494db71d1..90c99317bd7 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -377,6 +377,16 @@ TEST_F(FormatTestJS, AmbientDeclarations) {
"declare function\n"
"x();", // TODO(martinprobst): should ideally be indented.
NineCols);
+ verifyFormat("declare function foo();\n"
+ "let x = 1;\n");
+ verifyFormat("declare function foo(): string;\n"
+ "let x = 1;\n");
+ verifyFormat("declare function foo(): {x: number};\n"
+ "let x = 1;\n");
+ verifyFormat("declare class X {}\n"
+ "let x = 1;\n");
+ verifyFormat("declare interface Y {}\n"
+ "let x = 1;\n");
verifyFormat(
"declare enum X {\n"
"}",
OpenPOWER on IntegriCloud