[PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

Manuel Klimek via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 18 08:37:21 PDT 2016

klimek added inline comments.

Comment at: lib/Format/Format.cpp:1450
@@ -1447,3 +1449,3 @@
-  Formatter(const FormatStyle &Style, SourceManager &SourceMgr, FileID ID,
-            ArrayRef<CharSourceRange> Ranges)
+  CodeProcessor(const FormatStyle &Style, SourceManager &SourceMgr, FileID ID,
+                ArrayRef<CharSourceRange> Ranges)
After pondering a bit more, it seems like CodeProcessor is too generic: this is more something that runs analyses based on annotated tokens, so I'd call it TokenAnalyzer or something. That would also make it obvious to push some of the duplicated functionality from Formatter and Cleaner down (namely everything up to where we have generated the annotated tokens).

I'm still not completely convinced either way regarding inheritance vs. composition, but if we have a TokenAnalyzer, we'd also have a nice is-a relationship. While I generally agree to prefer composition, I also think we need to look out for where inheritance actually makes things clearer.


More information about the cfe-commits mailing list