MCPcopy Create free account
hub / github.com/KDAB/codebrowser / getSpecializedCursorTemplate

Function getSpecializedCursorTemplate

generator/annotator.cpp:857–894  ·  view source on GitHub ↗

basically loosely inspired from clang_getSpecializedCursorTemplate

Source from the content-addressed store, hash-verified

855
856//basically loosely inspired from clang_getSpecializedCursorTemplate
857static clang::NamedDecl *getSpecializedCursorTemplate(clang::NamedDecl *D) {
858 using namespace clang;
859 using namespace llvm;
860 NamedDecl *Template = 0;
861 if (CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(D)) {
862 ClassTemplateDecl* CXXRecordT = 0;
863 if (ClassTemplatePartialSpecializationDecl *PartialSpec = dyn_cast<ClassTemplatePartialSpecializationDecl>(CXXRecord))
864 CXXRecordT = PartialSpec->getSpecializedTemplate();
865 else if (ClassTemplateSpecializationDecl *ClassSpec = dyn_cast<ClassTemplateSpecializationDecl>(CXXRecord)) {
866 llvm::PointerUnion<ClassTemplateDecl *,
867 ClassTemplatePartialSpecializationDecl *> Result
868 = ClassSpec->getSpecializedTemplateOrPartial();
869 if (Result.is<ClassTemplateDecl *>())
870 CXXRecordT = Result.get<ClassTemplateDecl *>();
871 else
872 D = CXXRecord = Result.get<ClassTemplatePartialSpecializationDecl *>();
873 }
874 if (CXXRecordT)
875 D = CXXRecord = CXXRecordT->getTemplatedDecl();
876 Template = CXXRecord->getInstantiatedFromMemberClass();
877 } else if (FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
878 FunctionTemplateDecl* FunctionT = Function->getPrimaryTemplate();
879 if (FunctionT) {
880 if (auto Ins = FunctionT->getInstantiatedFromMemberTemplate())
881 FunctionT = Ins;
882 D = Function = FunctionT->getTemplatedDecl();
883 }
884 Template = Function->getInstantiatedFromMemberFunction();
885 } else if (VarDecl *Var = dyn_cast<VarDecl>(D)) {
886 if (Var->isStaticDataMember())
887 Template = Var->getInstantiatedFromStaticDataMember();
888 } else if (RedeclarableTemplateDecl *Tmpl = dyn_cast<RedeclarableTemplateDecl>(D)) {
889 Template = Tmpl->getInstantiatedFromMemberTemplate();
890 }
891
892 if (Template) return Template;
893 else return D;
894}
895
896
897std::pair< std::string, std::string > Annotator::getReferenceAndTitle(clang::NamedDecl* decl)

Callers 1

getReferenceAndTitleMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected