[PATCH] Refactor clang-format's formatter.

Daniel Jasper djasper at google.com
Tue May 12 02:05:29 PDT 2015


Looks very nice now.


================
Comment at: lib/Format/UnwrappedLineFormatter.cpp:30
@@ +29,3 @@
+///
+/// When \c updateIndentForLine is called for each \c AnnotatedLine, \c
+/// getIndent() will return the indent for the last line \c updateIndentForLine
----------------
This should be stronger, i.e. updateIndentForLine must be called...

================
Comment at: lib/Format/UnwrappedLineFormatter.cpp:34
@@ +33,3 @@
+/// If the line is not formatted (and thus the indent does not change), calling
+/// \c updateLevelIndentFromUnmodifiedLine will cause subsequent lines on the
+/// same level to be indented at the same level as the given line.
----------------
This should somehow include that updateLevelIndentFromUnmodifiedLine needs to be called *in addition* to updateIndentForLine.

================
Comment at: lib/Format/UnwrappedLineFormatter.cpp:51
@@ +50,3 @@
+  /// next.
+  void updateIndentForLine(const AnnotatedLine &Line) {
+    Offset = getIndentOffset(*Line.First);
----------------
I'd probably just call this nextLine.

================
Comment at: lib/Format/UnwrappedLineFormatter.cpp:71
@@ +70,3 @@
+  /// method.
+  void updateLevelIndentFromUnmodifiedLine(const AnnotatedLine &Line) {
+    unsigned LevelIndent = Line.First->OriginalColumn;
----------------
maybe adjustToUnmodifiedLine

http://reviews.llvm.org/D9662

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list