[PATCH] D24572: [clang-tidy] Clean up code after applying replacements.

Eric Liu via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 15 01:33:08 PDT 2016


ioeric requested changes to this revision.
This revision now requires changes to proceed.

================
Comment at: clang-tidy/ClangTidy.cpp:25
@@ -24,2 +24,3 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/ASTConsumers.h"
----------------
Also add dependency on clangFormat?

================
Comment at: clang-tidy/ClangTidy.cpp:159
@@ +158,3 @@
+                                  R.getReplacementText());
+                  Replacements = Replacements.merge(tooling::Replacements(R));
+                } else {
----------------
Do you need to update `CanBeApplied` and `AppliedFixes` in this branch as well?

================
Comment at: clang-tidy/ClangTidy.cpp:202
@@ +201,3 @@
+                       << Buffer.getError().message() << "\n";
+          // FIXME: Maybe don't apply anything.
+          continue;
----------------
This `FIXME` is not very clear, i.e. does it mean don't apply anything for all files? Or just a single file?

================
Comment at: clang-tidy/ClangTidy.cpp:206
@@ +205,3 @@
+        StringRef Code = Buffer.get()->getBuffer();
+        format::FormatStyle Style = format::getLLVMStyle();
+        llvm::Expected<Replacements> CleanReplacements =
----------------
Add a `FIXME` here. 

And I think this might be a better workaround for now:
    format::FormatStyle InsertStyle = format::getStyle("file", File, "LLVM");


https://reviews.llvm.org/D24572





More information about the cfe-commits mailing list