/// Retrieve the set of partial specializations of this class
/// template.
llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
- getPartialSpecializations();
+ getPartialSpecializations() const;
ClassTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L,
DeclarationName Name, TemplateParameterList *Params,
/// Retrieve the partial specializations as an ordered list.
void getPartialSpecializations(
- SmallVectorImpl<ClassTemplatePartialSpecializationDecl *> &PS);
+ SmallVectorImpl<ClassTemplatePartialSpecializationDecl *> &PS) const;
/// Find a class template partial specialization with the given
/// type T.
}
llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
-ClassTemplateDecl::getPartialSpecializations() {
+ClassTemplateDecl::getPartialSpecializations() const {
LoadLazySpecializations();
return getCommonPtr()->PartialSpecializations;
}
}
void ClassTemplateDecl::getPartialSpecializations(
- SmallVectorImpl<ClassTemplatePartialSpecializationDecl *> &PS) {
+ SmallVectorImpl<ClassTemplatePartialSpecializationDecl *> &PS) const {
llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &PartialSpecs
= getPartialSpecializations();
PS.clear();
#include "clang/Tooling/Refactoring.h"
#include "clang/Tooling/Refactoring/Rename/USRFinder.h"
#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/STLExtras.h"
#include <algorithm>
#include <set>
return true;
}
- bool VisitClassTemplatePartialSpecializationDecl(
- const ClassTemplatePartialSpecializationDecl *PartialSpec) {
- PartialSpecs.push_back(PartialSpec);
- return true;
- }
-
private:
void handleCXXRecordDecl(const CXXRecordDecl *RecordDecl) {
if (!RecordDecl->getDefinition()) {
void handleClassTemplateDecl(const ClassTemplateDecl *TemplateDecl) {
for (const auto *Specialization : TemplateDecl->specializations())
addUSRsOfCtorDtors(Specialization);
-
- for (const auto *PartialSpec : PartialSpecs) {
- if (PartialSpec->getSpecializedTemplate() == TemplateDecl)
- addUSRsOfCtorDtors(PartialSpec);
- }
+ SmallVector<ClassTemplatePartialSpecializationDecl *, 4> PartialSpecs;
+ TemplateDecl->getPartialSpecializations(PartialSpecs);
+ llvm::for_each(PartialSpecs,
+ [&](const auto *Spec) { addUSRsOfCtorDtors(Spec); });
addUSRsOfCtorDtors(TemplateDecl->getTemplatedDecl());
}
std::set<std::string> USRSet;
std::vector<const CXXMethodDecl *> OverriddenMethods;
std::vector<const CXXMethodDecl *> InstantiatedMethods;
- std::vector<const ClassTemplatePartialSpecializationDecl *> PartialSpecs;
};
} // namespace