[PATCH] D70553: [clang-apply-replacements] Add command line option to overwrite readonly files.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 23 13:07:40 PST 2019


aaron.ballman added a comment.

Can you add a test case for this functionality?



================
Comment at: clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp:52
+static cl::opt<bool> ForceOverwriteReadOnly(
+    "force", cl::desc("Overwrite read-only files when applying replacements\n"),
+    cl::init(false), cl::cat(ReplacementCategory));
----------------
Missing full stop at the end of the string.

Also, it looks like this is doing something subtly different than what the help text says. It looks like this is overwriting the *permissions* of the file when applying replacements. Nothing seems to reset the permissions back to what they once were when the file is closed. Is that accurate?


================
Comment at: clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp:161
+      using namespace llvm::sys::fs;
+      if (auto ErrorOrPerms = getPermissions(FileName)) {
+        perms P = ErrorOrPerms.get();
----------------
Rather than spell out the type in the declaration name but use `auto`, how about: `ErrorOr<perms> EP` or something?


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70553/new/

https://reviews.llvm.org/D70553





More information about the cfe-commits mailing list