From 5614aef776d36e2eac36b8fef9c0ab356bb901d2 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Sat, 18 Jul 2009 00:34:07 +0000 Subject: Move the functionality of ASTContext::getCanonicalDecl(), into a virtual method Decl::getCanonicalDecl(). llvm-svn: 76273 --- clang/lib/AST/DeclTemplate.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'clang/lib/AST/DeclTemplate.cpp') diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp index f1bd1b67d21..e096e41aed2 100644 --- a/clang/lib/AST/DeclTemplate.cpp +++ b/clang/lib/AST/DeclTemplate.cpp @@ -98,6 +98,13 @@ void FunctionTemplateDecl::Destroy(ASTContext &C) { Decl::Destroy(C); } +FunctionTemplateDecl *FunctionTemplateDecl::getCanonicalDecl() { + FunctionTemplateDecl *FunTmpl = this; + while (FunTmpl->getPreviousDeclaration()) + FunTmpl = FunTmpl->getPreviousDeclaration(); + return FunTmpl; +} + FunctionTemplateDecl::Common *FunctionTemplateDecl::getCommonPtr() { // Find the first declaration of this function template. FunctionTemplateDecl *First = this; @@ -115,6 +122,13 @@ FunctionTemplateDecl::Common *FunctionTemplateDecl::getCommonPtr() { // ClassTemplateDecl Implementation //===----------------------------------------------------------------------===// +ClassTemplateDecl *ClassTemplateDecl::getCanonicalDecl() { + ClassTemplateDecl *Template = this; + while (Template->getPreviousDeclaration()) + Template = Template->getPreviousDeclaration(); + return Template; +} + ClassTemplateDecl *ClassTemplateDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, -- cgit v1.2.3