diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -392,8 +392,8 @@ // Limit this to being an access modifier that follows. if (AttrTok->isOneOf(tok::kw_public, tok::kw_private, tok::kw_protected, - tok::kw_class, tok::kw_static, tok::l_square, - Keywords.kw_internal)) { + tok::comment, tok::kw_class, tok::kw_static, + tok::l_square, Keywords.kw_internal)) { return true; } diff --git a/clang/unittests/Format/FormatTestCSharp.cpp b/clang/unittests/Format/FormatTestCSharp.cpp --- a/clang/unittests/Format/FormatTestCSharp.cpp +++ b/clang/unittests/Format/FormatTestCSharp.cpp @@ -228,6 +228,11 @@ " set;\n" " get;\n" "}"); + + verifyFormat( + "[DllImport(\"Hello\", EntryPoint = \"hello_world\")]\n" + "// The const char* returned by hello_world must not be deleted.\n" + "private static extern IntPtr HelloFromCpp();)"); } TEST_F(FormatTestCSharp, CSharpUsing) {