summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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