[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 07:09:22 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL373748: [clang-rename] Fix a crash when renaming a class without definition. (authored by hokein, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68459?vs=223194&id=223216#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68459

Files:
  cfe/trunk/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
  cfe/trunk/test/clang-rename/ForwardClassDecl.cpp


Index: cfe/trunk/test/clang-rename/ForwardClassDecl.cpp
===================================================================
--- cfe/trunk/test/clang-rename/ForwardClassDecl.cpp
+++ cfe/trunk/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
Index: cfe/trunk/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
===================================================================
--- cfe/trunk/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
+++ cfe/trunk/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.223216.patch
Type: text/x-patch
Size: 1035 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191004/c3f52904/attachment.bin>


More information about the cfe-commits mailing list