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