[PATCH] D19804: Make clang-format cleaner remove redundant commas/colons in constructor initializer list.

Daniel Jasper via cfe-commits cfe-commits at lists.llvm.org
Sun May 8 12:12:29 PDT 2016


djasper added inline comments.

================
Comment at: lib/Format/Format.cpp:1821
@@ +1820,3 @@
+      if (Line->Affected)
+        checkConstructorInitList(*Line);
+    }
----------------
Why are we restricting this to constructor initializers? I think we should directly be more generic and clean up different lists. Also, as an idea? Could we make this very generic and implement a function that analyzes a line for a specific sequence of tokens? E.g., I would assume that then the current checkConstructorInitList() could be written as:

  cleanupLeft(tok::comma, tok::comma);
  cleanupLeft(tok::comma, tok::l_brace);
  cleanupRight(tok::colon, tok::comma);
  cleanupLeft(tok::colon, tok::l_brace);

With cleanupLeft/Right meaning: Find this sequence of tokens (ignoring comments) and then clean up the left or the right side.

Not sure about the exact names of functions etc. What do you think?


http://reviews.llvm.org/D19804





More information about the cfe-commits mailing list