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))
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))
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits