[PATCH] D27651: [clang-format] Even with AlignConsecutiveDeclarations, PointerAlignment: Right should keep *s and &s to the right

Daniel Jasper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 16 22:13:06 PDT 2017


djasper added inline comments.


================
Comment at: lib/Format/WhitespaceManager.cpp:255
+    // If PointerAlignment is PAS_Right, keep *s or &s next to the token
+    if (Style.PointerAlignment == FormatStyle::PAS_Right &&
+        Changes[i].Spaces != 0) {
----------------
This needs to be implemented in the Matches function that is passed in. This function is by now used to align many different things and special casing a case of variable declaration alignment here can easily have unforeseen consequences.


================
Comment at: unittests/Format/FormatTest.cpp:7878
+            "  int const i   = 1;\n"
+            "  int     **j   = 2, ***k;\n"
+            "  int      &k   = i;\n"
----------------
This looks wrong to me. Wouldn't you want to align on the */& then? I.e.:

  int const i   = 1;
  int       **j = 2, ***k;
  int       &k  = i;


https://reviews.llvm.org/D27651





More information about the cfe-commits mailing list