From 29cda59a9d79b725229948b27c90c5ba9a554e0c Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 15 Apr 2013 12:38:20 +0000 Subject: [PATCH] Fix the storage class of method instantiations. We keep the "as written" storage class, but that is a fuzzy concept for instantiations. With this patch instantiations of methods of class templates now get a storage class that is based on the semantics of isStatic(). With this can simplify isStatic() itself. llvm-svn: 179521 --- clang/lib/AST/DeclCXX.cpp | 15 +-------------- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 4 ++-- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index c8a203a..2c7c4d3 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -1258,20 +1258,7 @@ bool CXXRecordDecl::mayBeAbstract() const { void CXXMethodDecl::anchor() { } bool CXXMethodDecl::isStatic() const { - const CXXMethodDecl *MD = this; - for (;;) { - const CXXMethodDecl *C = MD->getCanonicalDecl(); - if (C != MD) { - MD = C; - continue; - } - - FunctionTemplateSpecializationInfo *Info = - MD->getTemplateSpecializationInfo(); - if (!Info) - break; - MD = cast(Info->getTemplate()->getTemplatedDecl()); - } + const CXXMethodDecl *MD = getCanonicalDecl(); if (MD->getStorageClass() == SC_Static) return true; diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 868369e..2dbfeec 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1530,10 +1530,10 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, Conversion->isConstexpr(), Conversion->getLocEnd()); } else { + StorageClass SC = D->isStatic() ? SC_Static : SC_None; Method = CXXMethodDecl::Create(SemaRef.Context, Record, StartLoc, NameInfo, T, TInfo, - D->getStorageClass(), - D->isInlineSpecified(), + SC, D->isInlineSpecified(), D->isConstexpr(), D->getLocEnd()); } -- 2.7.4