diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-18 00:34:07 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-18 00:34:07 +0000 |
commit | b57a4fe73b8227c0dba651818b8495dfca61e530 (patch) | |
tree | 56854fb0f97e67a7dc7ef19ba5fedb56155a29a9 /lib/AST/ASTContext.cpp | |
parent | 0df134715d75c62422502af0f5610885a5a4f472 (diff) |
Move the functionality of ASTContext::getCanonicalDecl(), into a virtual method Decl::getCanonicalDecl().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76273 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 33 |
1 files changed, 1 insertions, 32 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index b43aadb62e..f680606dcf 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -2085,38 +2085,7 @@ QualType ASTContext::getCanonicalType(QualType T) { Decl *ASTContext::getCanonicalDecl(Decl *D) { if (!D) return 0; - - if (TagDecl *Tag = dyn_cast<TagDecl>(D)) { - QualType T = getTagDeclType(Tag); - return cast<TagDecl>(cast<TagType>(T.getTypePtr()->CanonicalType) - ->getDecl()); - } - - if (ClassTemplateDecl *Template = dyn_cast<ClassTemplateDecl>(D)) { - while (Template->getPreviousDeclaration()) - Template = Template->getPreviousDeclaration(); - return Template; - } - - if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) { - while (Function->getPreviousDeclaration()) - Function = Function->getPreviousDeclaration(); - return const_cast<FunctionDecl *>(Function); - } - - if (FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(D)) { - while (FunTmpl->getPreviousDeclaration()) - FunTmpl = FunTmpl->getPreviousDeclaration(); - return FunTmpl; - } - - if (const VarDecl *Var = dyn_cast<VarDecl>(D)) { - while (Var->getPreviousDeclaration()) - Var = Var->getPreviousDeclaration(); - return const_cast<VarDecl *>(Var); - } - - return D; + return D->getCanonicalDecl(); } TemplateName ASTContext::getCanonicalTemplateName(TemplateName Name) { |