r247750 - clang-format: In Java, `assert` is followed by an expression.
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 15 16:48:18 PDT 2015
Author: nico
Date: Tue Sep 15 18:48:17 2015
New Revision: 247750
URL: http://llvm.org/viewvc/llvm-project?rev=247750&view=rev
Log:
clang-format: In Java, `assert` is followed by an expression.
Before: assert a&& b;
Now: assert a && b;
Modified:
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJava.cpp
Modified: cfe/trunk/lib/Format/FormatToken.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=247750&r1=247749&r2=247750&view=diff
==============================================================================
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Tue Sep 15 18:48:17 2015
@@ -539,6 +539,7 @@ struct AdditionalKeywords {
kw_var = &IdentTable.get("var");
kw_abstract = &IdentTable.get("abstract");
+ kw_assert = &IdentTable.get("assert");
kw_extends = &IdentTable.get("extends");
kw_implements = &IdentTable.get("implements");
kw_instanceof = &IdentTable.get("instanceof");
@@ -580,6 +581,7 @@ struct AdditionalKeywords {
// Java keywords.
IdentifierInfo *kw_abstract;
+ IdentifierInfo *kw_assert;
IdentifierInfo *kw_extends;
IdentifierInfo *kw_implements;
IdentifierInfo *kw_instanceof;
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=247750&r1=247749&r2=247750&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Sep 15 18:48:17 2015
@@ -860,7 +860,7 @@ private:
Contexts.back().IsExpression = true;
} else if (Current.is(TT_TrailingReturnArrow)) {
Contexts.back().IsExpression = false;
- } else if (Current.is(TT_LambdaArrow)) {
+ } else if (Current.is(TT_LambdaArrow) || Current.is(Keywords.kw_assert)) {
Contexts.back().IsExpression = Style.Language == FormatStyle::LK_Java;
} else if (Current.is(tok::l_paren) && !Line.MustBeDeclaration &&
!Line.InPPDirective &&
Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=247750&r1=247749&r2=247750&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Tue Sep 15 18:48:17 2015
@@ -393,6 +393,11 @@ TEST_F(FormatTestJava, SynchronizedKeywo
"}");
}
+TEST_F(FormatTestJava, AssertKeyword) {
+ verifyFormat("assert a && b;");
+}
+
+
TEST_F(FormatTestJava, PackageDeclarations) {
verifyFormat("package some.really.loooooooooooooooooooooong.package;",
getStyleWithColumns(50));
More information about the cfe-commits
mailing list