forked from OSchip/llvm-project
[clang-rename] Simplify the code of handling class paritial specializations, NFC.
Instead of collecting all specializations and doing a post-filterin, we can just get all targeted specializations from getPartialSpecializationsizations. Differential Revision: https://reviews.llvm.org/D89220
This commit is contained in:
parent
dc128e5968
commit
27c691cf62
|
@ -2266,7 +2266,7 @@ protected:
|
||||||
/// Retrieve the set of partial specializations of this class
|
/// Retrieve the set of partial specializations of this class
|
||||||
/// template.
|
/// template.
|
||||||
llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
|
llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
|
||||||
getPartialSpecializations();
|
getPartialSpecializations() const;
|
||||||
|
|
||||||
ClassTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L,
|
ClassTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L,
|
||||||
DeclarationName Name, TemplateParameterList *Params,
|
DeclarationName Name, TemplateParameterList *Params,
|
||||||
|
@ -2363,7 +2363,7 @@ public:
|
||||||
|
|
||||||
/// Retrieve the partial specializations as an ordered list.
|
/// Retrieve the partial specializations as an ordered list.
|
||||||
void getPartialSpecializations(
|
void getPartialSpecializations(
|
||||||
SmallVectorImpl<ClassTemplatePartialSpecializationDecl *> &PS);
|
SmallVectorImpl<ClassTemplatePartialSpecializationDecl *> &PS) const;
|
||||||
|
|
||||||
/// Find a class template partial specialization with the given
|
/// Find a class template partial specialization with the given
|
||||||
/// type T.
|
/// type T.
|
||||||
|
|
|
@ -440,7 +440,7 @@ ClassTemplateDecl::getSpecializations() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
|
llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
|
||||||
ClassTemplateDecl::getPartialSpecializations() {
|
ClassTemplateDecl::getPartialSpecializations() const {
|
||||||
LoadLazySpecializations();
|
LoadLazySpecializations();
|
||||||
return getCommonPtr()->PartialSpecializations;
|
return getCommonPtr()->PartialSpecializations;
|
||||||
}
|
}
|
||||||
|
@ -528,7 +528,7 @@ void ClassTemplateDecl::AddPartialSpecialization(
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClassTemplateDecl::getPartialSpecializations(
|
void ClassTemplateDecl::getPartialSpecializations(
|
||||||
SmallVectorImpl<ClassTemplatePartialSpecializationDecl *> &PS) {
|
SmallVectorImpl<ClassTemplatePartialSpecializationDecl *> &PS) const {
|
||||||
llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &PartialSpecs
|
llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &PartialSpecs
|
||||||
= getPartialSpecializations();
|
= getPartialSpecializations();
|
||||||
PS.clear();
|
PS.clear();
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "clang/Tooling/Refactoring.h"
|
#include "clang/Tooling/Refactoring.h"
|
||||||
#include "clang/Tooling/Refactoring/Rename/USRFinder.h"
|
#include "clang/Tooling/Refactoring/Rename/USRFinder.h"
|
||||||
#include "clang/Tooling/Tooling.h"
|
#include "clang/Tooling/Tooling.h"
|
||||||
|
#include "llvm/ADT/STLExtras.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
@ -96,12 +97,6 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VisitClassTemplatePartialSpecializationDecl(
|
|
||||||
const ClassTemplatePartialSpecializationDecl *PartialSpec) {
|
|
||||||
PartialSpecs.push_back(PartialSpec);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleCXXRecordDecl(const CXXRecordDecl *RecordDecl) {
|
void handleCXXRecordDecl(const CXXRecordDecl *RecordDecl) {
|
||||||
if (!RecordDecl->getDefinition()) {
|
if (!RecordDecl->getDefinition()) {
|
||||||
|
@ -118,11 +113,10 @@ private:
|
||||||
void handleClassTemplateDecl(const ClassTemplateDecl *TemplateDecl) {
|
void handleClassTemplateDecl(const ClassTemplateDecl *TemplateDecl) {
|
||||||
for (const auto *Specialization : TemplateDecl->specializations())
|
for (const auto *Specialization : TemplateDecl->specializations())
|
||||||
addUSRsOfCtorDtors(Specialization);
|
addUSRsOfCtorDtors(Specialization);
|
||||||
|
SmallVector<ClassTemplatePartialSpecializationDecl *, 4> PartialSpecs;
|
||||||
for (const auto *PartialSpec : PartialSpecs) {
|
TemplateDecl->getPartialSpecializations(PartialSpecs);
|
||||||
if (PartialSpec->getSpecializedTemplate() == TemplateDecl)
|
llvm::for_each(PartialSpecs,
|
||||||
addUSRsOfCtorDtors(PartialSpec);
|
[&](const auto *Spec) { addUSRsOfCtorDtors(Spec); });
|
||||||
}
|
|
||||||
addUSRsOfCtorDtors(TemplateDecl->getTemplatedDecl());
|
addUSRsOfCtorDtors(TemplateDecl->getTemplatedDecl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +178,6 @@ private:
|
||||||
std::set<std::string> USRSet;
|
std::set<std::string> USRSet;
|
||||||
std::vector<const CXXMethodDecl *> OverriddenMethods;
|
std::vector<const CXXMethodDecl *> OverriddenMethods;
|
||||||
std::vector<const CXXMethodDecl *> InstantiatedMethods;
|
std::vector<const CXXMethodDecl *> InstantiatedMethods;
|
||||||
std::vector<const ClassTemplatePartialSpecializationDecl *> PartialSpecs;
|
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue