r217158 - clang-format: [JS] Supprot "catch" as function name.
Daniel Jasper
djasper at google.com
Thu Sep 4 08:03:34 PDT 2014
Author: djasper
Date: Thu Sep 4 10:03:34 2014
New Revision: 217158
URL: http://llvm.org/viewvc/llvm-project?rev=217158&view=rev
Log:
clang-format: [JS] Supprot "catch" as function name.
Before:
someObject.catch ();
After:
someObject.catch();
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=217158&r1=217157&r2=217158&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Sep 4 10:03:34 2014
@@ -1586,7 +1586,9 @@ bool TokenAnnotator::spaceRequiredBetwee
Left.isOneOf(tok::kw_new, tok::kw_delete, tok::semi) ||
(Style.SpaceBeforeParens != FormatStyle::SBPO_Never &&
(Left.isOneOf(tok::kw_if, tok::kw_for, tok::kw_while,
- tok::kw_switch, tok::kw_catch, tok::kw_case) ||
+ tok::kw_switch, tok::kw_case) ||
+ (Left.is(tok::kw_catch) &&
+ (!Left.Previous || Left.Previous->isNot(tok::period))) ||
Left.IsForEachMacro)) ||
(Style.SpaceBeforeParens == FormatStyle::SBPO_Always &&
(Left.is(tok::identifier) || Left.isFunctionLikeKeyword()) &&
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=217158&r1=217157&r2=217158&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Thu Sep 4 10:03:34 2014
@@ -254,6 +254,9 @@ TEST_F(FormatTestJS, TryCatch) {
"} finally {\n"
" h();\n"
"}");
+
+ // But, of course, "catch" is a perfectly fine function name in JavaScript.
+ verifyFormat("someObject.catch();");
}
TEST_F(FormatTestJS, StringLiteralConcatenation) {
More information about the cfe-commits
mailing list