[PATCH] D148467: [clang-format] Add a new AfterCSharpProperty to BraceWrapping

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 20 00:34:40 PDT 2023


HazardyKnusperkeks added inline comments.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:21
 #include "llvm/Support/Debug.h"
+#include <sal.h>
 
----------------
What is this?


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:5023-5026
+      // string Foo
+      // {
+      //     set; interal get {};
+      // }
----------------
Isn't the example wrong?


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:5044
 
+  // The handling of C# properties and auto-properties
+  if (Style.isCSharp()) {
----------------



================
Comment at: clang/lib/Format/TokenAnnotator.cpp:5052
+
+    // Handle non short property on a single line
+    // string Foo {
----------------



================
Comment at: clang/lib/Format/TokenAnnotator.cpp:5059
+      if (Left.is(tok::l_brace) &&
+          Right.isOneOf(Keywords.kw_set, Keywords.kw_get, Keywords.kw_init)) {
+        return true;
----------------
This gets keeping repeated, maybe put it in a own function?


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:5066-5067
+      if (Left.is(tok::l_brace) &&
+          Right.isOneOf(tok::kw_public, tok::kw_private, tok::kw_protected,
+                        Keywords.kw_internal) &&
+          Right.Next &&
----------------
Same here.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:5105
+        return Style.AlwaysBreakBetweenShortCSharpProperties;
+        ;
+      }
----------------
Drop


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:5113-5115
+    if (Style.BraceWrapping.AfterCSharpProperty &&
+        ((Left.is(tok::l_brace) &&
+          Right.isOneOf(Keywords.kw_set, Keywords.kw_get, Keywords.kw_init)))) {
----------------
A bit too much parens.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:5125
+    if (Style.BraceWrapping.AfterCSharpProperty &&
+        (Left.is(tok::semi) && Right.is(tok::r_brace))) {
+      return true;
----------------
Also not needed.


================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2076-2078
+  if ((!IsTrivialPropertyAccessor &&
+       Style.AllowShortCSharpPropertiesOnASingleLine) &&
+      Style.BraceWrapping.AfterFunction) {
----------------



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148467/new/

https://reviews.llvm.org/D148467



More information about the cfe-commits mailing list