[PATCH] clang-apply-replacements: Add code-formatting post processing step
Daniel Jasper
djasper at google.com
Thu Sep 26 09:06:00 PDT 2013
A few remarks .. But I need to think about some of this in more depth.
================
Comment at: clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp:173
@@ +172,3 @@
+
+ for (FileToReplacementsMap::const_iterator I = GroupedReplacements.begin(),
+ E = GroupedReplacements.end(); I != E; ++I) {
----------------
Use clang-format.
================
Comment at: clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp:185
@@ +184,3 @@
+ if (DoFormat) {
+ FileManager FormattingFiles((FileSystemOptions()));
+ SourceManager FormattingSM(Diagnostics, FormattingFiles);
----------------
I think everything in "if (DoFormat)" should be pulled out into a function.
================
Comment at: clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp:175
@@ +174,3 @@
+ E = GroupedReplacements.end(); I != E; ++I) {
+ if (!tooling::applyAllReplacements(I->getValue(), ReplacementsRewriter)) {
+ errs() << "Failed to apply replacements to " << I->getKey() << "\n";
----------------
I would pull applyAllReplacements and getNewDataFor into a single function with the signature:
bool applyReplacements(std::vector<Replacements> Changes, string &Result);
The Rewriter and SourceManager can be created in that function.
http://llvm-reviews.chandlerc.com/D1730
More information about the cfe-commits
mailing list