[PATCH] D37695: [clang-format] Break non-trailing comments, try 2

Daniel Jasper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 26 15:31:06 PDT 2017


djasper added inline comments.


================
Comment at: lib/Format/ContinuationIndenter.h:270
+  // \c breakProtrudingToken.
+  bool LastBlockCommentWasBroken : 1;
+
----------------
We should be *very* careful when adding stuff to ParenState as every extra bit of data and every extra comparison can have substantial cost.

Here, specifically:


  - Make this more generic. This currently addresses a very specific use case (comment broken), whereas the action is probably always going to be the same (enforce break). I think we should call this "NoContinuation" or "NeedsNewline" or something.
  - This seems always to only relate to the previous token. So it can be always reset when the state is moved further.
  - As this always refers to the previous token, this can probably live in LineState instead of ParenState. That way, it has less runtime/space overhead.




https://reviews.llvm.org/D37695





More information about the cfe-commits mailing list