[PATCH] D148439: [clang-rename] Exit gracefully when no input provided
Shivam Gupta via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 26 07:55:04 PDT 2023
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG62eec1584d2c: [clang-rename] Exit gracefully when no input provided (authored by xgupta).
Changed prior to commit:
https://reviews.llvm.org/D148439?vs=514842&id=517178#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148439/new/
https://reviews.llvm.org/D148439
Files:
clang/docs/ReleaseNotes.rst
clang/test/clang-rename/NonExistFile.cpp
clang/tools/clang-rename/ClangRename.cpp
Index: clang/tools/clang-rename/ClangRename.cpp
===================================================================
--- clang/tools/clang-rename/ClangRename.cpp
+++ clang/tools/clang-rename/ClangRename.cpp
@@ -229,6 +229,10 @@
Tool.applyAllReplacements(Rewrite);
for (const auto &File : Files) {
auto Entry = FileMgr.getFile(File);
+ if (!Entry) {
+ errs() << "clang-rename: " << File << " does not exist.\n";
+ return 1;
+ }
const auto ID = Sources.getOrCreateFileID(*Entry, SrcMgr::C_User);
Rewrite.getEditBuffer(ID).write(outs());
}
Index: clang/test/clang-rename/NonExistFile.cpp
===================================================================
--- /dev/null
+++ clang/test/clang-rename/NonExistFile.cpp
@@ -0,0 +1,2 @@
+// RUN: not clang-rename -offset=0 -new-name=bar non-existing-file 2>&1 | FileCheck %s
+// CHECK: clang-rename: non-existing-file does not exist.
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -235,6 +235,8 @@
Bug Fixes in This Version
-------------------------
+- Fix segfault while running clang-rename on a non existing file.
+ (`#36471 <https://github.com/llvm/llvm-project/issues/36471>`_)
- Fix crash when diagnosing incorrect usage of ``_Nullable`` involving alias
templates.
(`#60344 <https://github.com/llvm/llvm-project/issues/60344>`_)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148439.517178.patch
Type: text/x-patch
Size: 1470 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230426/e5b57a41/attachment-0001.bin>
More information about the cfe-commits
mailing list