[PATCH] D31635: [clang-format] Added ReferenceAlignmentStyle option

MyDeveloperDay via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 8 00:29:28 PDT 2019


MyDeveloperDay added a comment.

Thank you for the patch, just a couple of minor things (the doc is important).

As Astyle has this option I think this is a gap in clang-format (this is also not the first request I've seen for this https://bugs.llvm.org/show_bug.cgi?id=42165)

Given your project is waiting to use it (https://github.com/x64dbg/x64dbg) and the number of forks/stars I think we should consider this a significant enough project using this style to warrant it being worth landing.



================
Comment at: clang/include/clang/Format/Format.h:1681
+  /// \brief The ``&`` and ``&&`` alignment style.
+  enum ReferenceAlignmentStyle {
+    /// Align reference like ``PointerAlignment``.
----------------
You are missing a documentation change (there is a python script which update the ClangFormatStyleOption.rst from this header)


================
Comment at: clang/unittests/Format/FormatTest.cpp:857
+  verifyFormat("int&& f3(int& b, int&& c, int* a);", Style);
+  verifyFormat("int* a = f1();\nint& b = f2();\nint&& c = f3();", Style);
+  Style.PointerAlignment = FormatStyle::PAS_Right;
----------------
Nit: for completeness (I might be tempted to add the other styles `PAS_Middle` and `PAS_Right` for pointer alignment where `ReferenceAlignment` is RAS_Pointer (given there is code which checks)

```getTokenPointerAlignment(Left) != FormatStyle::PAS_Right```


================
Comment at: clang/unittests/Format/FormatTest.cpp:876
+  verifyFormat("int * a = f1();\nint &b = f2();\nint &&c = f3();", Style);
+}
+
----------------
add your example as a test just comment it out and add FIXME if it doesn't work, then it will tell people this is what we are aiming for.


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

https://reviews.llvm.org/D31635





More information about the llvm-commits mailing list