Author: Jonathan Coe Date: 2020-02-04T19:00:54Z New Revision: 50d8977c459de302fcef7a2578b0e8f8862a2fe0
URL: https://github.com/llvm/llvm-project/commit/50d8977c459de302fcef7a2578b0e8f8862a2fe0 DIFF: https://github.com/llvm/llvm-project/commit/50d8977c459de302fcef7a2578b0e8f8862a2fe0.diff LOG: [clang-format] Allow a comment to follow a C# attribute specifier Summary: Add comments to the list of tokens that can follow the ']' at the end of a C# attribute specifier to prevent comments after attribute specifiers from being formatted as continuations. Reviewers: MyDeveloperDay, krasimir Reviewed By: MyDeveloperDay Tags: #clang-format Differential Revision: https://reviews.llvm.org/D73977 Added: Modified: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTestCSharp.cpp Removed: ################################################################################ diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index f6df58dac2d6..7538b03f4f7c 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -392,8 +392,8 @@ class AnnotatingParser { // 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 index 5d1131aa0c3a..86a44d0f9eb3 100644 --- a/clang/unittests/Format/FormatTestCSharp.cpp +++ b/clang/unittests/Format/FormatTestCSharp.cpp @@ -228,6 +228,11 @@ TEST_F(FormatTestCSharp, Attributes) { " 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) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits