diff options
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 57149af3c10..aec3b7cd3bd 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -196,6 +196,17 @@ bool Decl::isTemplateDecl() const { return isa<TemplateDecl>(this); } +TemplateDecl *Decl::getDescribedTemplate() const { + if (auto *FD = dyn_cast<FunctionDecl>(this)) + return FD->getDescribedFunctionTemplate(); + else if (auto *RD = dyn_cast<CXXRecordDecl>(this)) + return RD->getDescribedClassTemplate(); + else if (auto *VD = dyn_cast<VarDecl>(this)) + return VD->getDescribedVarTemplate(); + + return nullptr; +} + const DeclContext *Decl::getParentFunctionOrMethod() const { for (const DeclContext *DC = getDeclContext(); DC && !DC->isTranslationUnit() && !DC->isNamespace(); |