summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-11-26 11:20:43 +0000
committerDaniel Jasper <djasper@google.com>2014-11-26 11:20:43 +0000
commit07013a42d2f13043ee1237071f41361cecc581ff (patch)
tree2da0fef489a2e0d1c2e73dd38218e95e86ba829e /clang
parent2db4107a36938782ed70546384e840d2ecd60c61 (diff)
downloadbcm5719-llvm-07013a42d2f13043ee1237071f41361cecc581ff.tar.gz
bcm5719-llvm-07013a42d2f13043ee1237071f41361cecc581ff.zip
clang-format: [Java] Fix breaking after annotations.
Before: @Annotation1 // comment @Annotation2 class C {} After: @Annotation1 // comment @Annotation2 class C {} llvm-svn: 222825
Diffstat (limited to 'clang')
-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 3daea77f968..9b32c35601f 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -864,7 +864,8 @@ private:
Current.Previous->is(tok::at) &&
Current.isNot(Keywords.kw_interface)) {
const FormatToken &AtToken = *Current.Previous;
- if (!AtToken.Previous || AtToken.Previous->is(TT_LeadingJavaAnnotation))
+ const FormatToken *Previous = AtToken.getPreviousNonComment();
+ if (!Previous || Previous->is(TT_LeadingJavaAnnotation))
Current.Type = TT_LeadingJavaAnnotation;
else
Current.Type = TT_JavaAnnotation;
diff --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp
index 946ae32d874..5c80babf26e 100644
--- a/clang/unittests/Format/FormatTestJava.cpp
+++ b/clang/unittests/Format/FormatTestJava.cpp
@@ -206,6 +206,9 @@ TEST_F(FormatTestJava, Annotations) {
verifyFormat("@Override\n"
"@Nullable\n"
"public String getNameIfPresent() {}");
+ verifyFormat("@Override // comment\n"
+ "@Nullable\n"
+ "public String getNameIfPresent() {}");
verifyFormat("@SuppressWarnings(value = \"unchecked\")\n"
"public void doSomething() {}");
OpenPOWER on IntegriCloud