summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/UnwrappedLineParser.cpp
diff options
context:
space:
mode:
authorMartin Probst <martin@probst.io>2017-01-04 13:36:43 +0000
committerMartin Probst <martin@probst.io>2017-01-04 13:36:43 +0000
commitaf16c50639289fd0875100519a1161bc7058f215 (patch)
tree098d37863a9dbf232f01cfc54182517103be6db6 /clang/lib/Format/UnwrappedLineParser.cpp
parent039368e2d2184245ed3888eeb87dedd6fcd599ac (diff)
downloadbcm5719-llvm-af16c50639289fd0875100519a1161bc7058f215.tar.gz
bcm5719-llvm-af16c50639289fd0875100519a1161bc7058f215.zip
clang-format: [JS] avoid indent after ambient function declarations.
Summary: Before: declare function foo(); let x = 1; After: declare function foo(); let x = 1; The problem was that clang-format would unconditionally try to parse a child block, even though ambient function declarations do not have a body (similar to forward declarations). Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D28246 llvm-svn: 290959
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.cpp')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp5
1 files changed, 4 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();
}
OpenPOWER on IntegriCloud