hokein created this revision. hokein added a reviewer: kbobyrev. Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, ilya-biryukov. Herald added a project: clang.
This fixes a clangd rename issue, which is missing the reference of an incomplete specialization. Unfortunately, I didn't reproduce this issue in clang-rename, I guess the input `FoundDecl` of AdditionalUSRFinder is different in clangd vs clang-rename, clang-rename uses the underlying CXXRecordDecl of the ClassTemplateDecl, which is fixed in https://github.com/llvm/llvm-project/commit/5d862c042b52ae2aad37471d0b83b6c678a520e3; while clangd-rename uses the ClassTemplateDecl. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D74829 Files: clang-tools-extra/clangd/unittests/RenameTests.cpp clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp Index: clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp =================================================================== --- clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp +++ clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp @@ -126,12 +126,14 @@ addUSRsOfCtorDtors(TemplateDecl->getTemplatedDecl()); } - void addUSRsOfCtorDtors(const CXXRecordDecl *RecordDecl) { - RecordDecl = RecordDecl->getDefinition(); + void addUSRsOfCtorDtors(const CXXRecordDecl *RD) { + const auto* RecordDecl = RD->getDefinition(); // Skip if the CXXRecordDecl doesn't have definition. - if (!RecordDecl) + if (!RecordDecl) { + USRSet.insert(getUSRForDecl(RD)); return; + } for (const auto *CtorDecl : RecordDecl->ctors()) USRSet.insert(getUSRForDecl(CtorDecl)); Index: clang-tools-extra/clangd/unittests/RenameTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/RenameTests.cpp +++ clang-tools-extra/clangd/unittests/RenameTests.cpp @@ -202,6 +202,13 @@ } )cpp", + // Incomplete class specializations + R"cpp( + template <typename T> + class [[Fo^o]] {}; + void func([[Foo]]<int>); + )cpp", + // Template class instantiations. R"cpp( template <typename T>
Index: clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp =================================================================== --- clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp +++ clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp @@ -126,12 +126,14 @@ addUSRsOfCtorDtors(TemplateDecl->getTemplatedDecl()); } - void addUSRsOfCtorDtors(const CXXRecordDecl *RecordDecl) { - RecordDecl = RecordDecl->getDefinition(); + void addUSRsOfCtorDtors(const CXXRecordDecl *RD) { + const auto* RecordDecl = RD->getDefinition(); // Skip if the CXXRecordDecl doesn't have definition. - if (!RecordDecl) + if (!RecordDecl) { + USRSet.insert(getUSRForDecl(RD)); return; + } for (const auto *CtorDecl : RecordDecl->ctors()) USRSet.insert(getUSRForDecl(CtorDecl)); Index: clang-tools-extra/clangd/unittests/RenameTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/RenameTests.cpp +++ clang-tools-extra/clangd/unittests/RenameTests.cpp @@ -202,6 +202,13 @@ } )cpp", + // Incomplete class specializations + R"cpp( + template <typename T> + class [[Fo^o]] {}; + void func([[Foo]]<int>); + )cpp", + // Template class instantiations. R"cpp( template <typename T>
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits