r373748 - [clang-rename] Fix a crash when renaming a class without definition.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 4 07:09:32 PDT 2019
Author: hokein
Date: Fri Oct 4 07:09:31 2019
New Revision: 373748
URL: http://llvm.org/viewvc/llvm-project?rev=373748&view=rev
Log:
[clang-rename] Fix a crash when renaming a class without definition.
Reviewers: sammccall
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D68459
Added:
cfe/trunk/test/clang-rename/ForwardClassDecl.cpp
Modified:
cfe/trunk/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
Modified: cfe/trunk/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp?rev=373748&r1=373747&r2=373748&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp Fri Oct 4 07:09:31 2019
@@ -102,6 +102,10 @@ public:
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))
Added: cfe/trunk/test/clang-rename/ForwardClassDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/clang-rename/ForwardClassDecl.cpp?rev=373748&view=auto
==============================================================================
--- cfe/trunk/test/clang-rename/ForwardClassDecl.cpp (added)
+++ cfe/trunk/test/clang-rename/ForwardClassDecl.cpp Fri Oct 4 07:09:31 2019
@@ -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
More information about the cfe-commits
mailing list