summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-10-21 11:17:56 +0000
committerDaniel Jasper <djasper@google.com>2014-10-21 11:17:56 +0000
commitd78c42237873af0dff693e9f6a691ba877d61b1a (patch)
tree06a3001d81d3fe8ec84e874255a5a182f70e3124
parent5ffcb7fe908166911891c697d56a582b4a836bf0 (diff)
downloadbcm5719-llvm-d78c42237873af0dff693e9f6a691ba877d61b1a.tar.gz
bcm5719-llvm-d78c42237873af0dff693e9f6a691ba877d61b1a.zip
clang-format: [Java] Fix formatting of multiple annotations.
Before: @SuppressWarnings(value = "unchecked") @Author(name = "abc") public void doSomething() { } After: @SuppressWarnings(value = "unchecked") @Author(name = "abc") public void doSomething() { } llvm-svn: 220286
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp3
-rw-r--r--clang/unittests/Format/FormatTestJava.cpp3
2 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 4b39b507359..db0e9316598 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -827,7 +827,8 @@ private:
PreviousNoComment->isOneOf(tok::comma, tok::l_brace))
Current.Type = TT_DesignatedInitializerPeriod;
} else if (Current.isOneOf(tok::identifier, tok::kw_const) &&
- Current.Previous && Current.Previous->isNot(tok::equal) &&
+ Current.Previous &&
+ !Current.Previous->isOneOf(tok::equal, tok::at) &&
Line.MightBeFunctionDecl && Contexts.size() == 1) {
// Line.MightBeFunctionDecl can only be true after the parentheses of a
// function declaration have been found.
diff --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp
index f7d85fc4a0e..d38a8070bdc 100644
--- a/clang/unittests/Format/FormatTestJava.cpp
+++ b/clang/unittests/Format/FormatTestJava.cpp
@@ -74,6 +74,9 @@ TEST_F(FormatTestJava, Annotations) {
verifyFormat("@SuppressWarnings(value = \"unchecked\")\n"
"public void doSomething() {\n}");
+ verifyFormat("@SuppressWarnings(value = \"unchecked\")\n"
+ "@Author(name = \"abc\")\n"
+ "public void doSomething() {\n}");
verifyFormat("DoSomething(new A() {\n"
" @Override\n"
OpenPOWER on IntegriCloud