[PATCH] D68459: [clang-rename] Fix a crash when renaming a class without definition.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 4 05:27:29 PDT 2019
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: clang.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D68459
Files:
clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
clang/test/clang-rename/ForwardClassDecl.cpp
Index: clang/test/clang-rename/ForwardClassDecl.cpp
===================================================================
--- /dev/null
+++ clang/test/clang-rename/ForwardClassDecl.cpp
@@ -0,0 +1,4 @@
+class Foo; // CHECK: class Bar;
+Foo *f(); // CHECK: Bar *f();
+
+// RUN: clang-rename -offset=6 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
\ No newline at end of file
Index: clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
===================================================================
--- clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
@@ -102,6 +102,10 @@
private:
void handleCXXRecordDecl(const CXXRecordDecl *RecordDecl) {
+ if (!RecordDecl->getDefinition()) {
+ USRSet.insert(getUSRForDecl(RecordDecl));
+ return;
+ }
RecordDecl = RecordDecl->getDefinition();
if (const auto *ClassTemplateSpecDecl =
dyn_cast<ClassTemplateSpecializationDecl>(RecordDecl))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68459.223194.patch
Type: text/x-patch
Size: 1004 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191004/99c20c4b/attachment.bin>
More information about the cfe-commits
mailing list