[PATCH] D148439: [clang-rename] Exit gracefully when no input provided
Kirill Bobyrev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 18 16:32:56 PDT 2023
kbobyrev requested changes to this revision.
kbobyrev added a comment.
This revision now requires changes to proceed.
Yeah, this should be a right approach! Thanks!
================
Comment at: clang/test/clang-rename/NonExistFile.cpp:1
+// RUN: not clang-rename -offset=0 -new-name=plop asdasd 2>&1 | FileCheck %s
+// CHECK: clang-rename: input file does not exist.
----------------
Rather than `asdasd` please use a meaningful name (e.g. `non-existing-file`).
================
Comment at: clang/tools/clang-rename/ClangRename.cpp:233
+ if (!Entry) {
+ errs() << "clang-rename: input file does not exist.\n";
+ return 1;
----------------
It is worth including the filename in the error message, otherwise it won't be possible to understand which one is missing (there can be multiple IIRC, right?).
Also, it's better to put this check to the top of main, where the `OP` if first declared, since this is a sanity check and we want to fail if the inputs are corrupted.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148439/new/
https://reviews.llvm.org/D148439
More information about the cfe-commits
mailing list