diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 13 | ||||
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 15 | ||||
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 7 |
3 files changed, 22 insertions, 13 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 6c620713f76..063914092ee 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -528,19 +528,6 @@ OverloadedOperatorKind FunctionDecl::getOverloadedOperator() const { // TagDecl Implementation //===----------------------------------------------------------------------===// -bool TagDecl::isDependentType() const { - if (const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(this)) - if (Record->getDescribedClassTemplate()) - return true; - - if (const TagDecl *TD = dyn_cast_or_null<TagDecl>(getDeclContext())) - return TD->isDependentType(); - - // FIXME: Tag types declared function templates are dependent types. - // FIXME: Look through block scopes. - return false; -} - void TagDecl::startDefinition() { TagType *TagT = const_cast<TagType *>(TypeForDecl->getAsTagType()); TagT->decl.setPointer(this); diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 071fb791013..ba8f3351c3a 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -396,6 +396,21 @@ void DeclContext::DestroyDecls(ASTContext &C) { (*D++)->Destroy(C); } +bool DeclContext::isDependentContext() const { + if (isFileContext()) + return false; + + if (const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(this)) + if (Record->getDescribedClassTemplate()) + return true; + + if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(this)) + if (Function->getDescribedFunctionTemplate()) + return true; + + return getParent() && getParent()->isDependentContext(); +} + bool DeclContext::isTransparentContext() const { if (DeclKind == Decl::Enum) return true; // FIXME: Check for C++0x scoped enums diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 33eedcec38a..39e455a6ec7 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -97,6 +97,9 @@ Decl *TemplateDeclInstantiator::VisitTypedefDecl(TypedefDecl *D) { Typedef->setInvalidDecl(); Owner->addDecl(SemaRef.Context, Typedef); + if (Owner->isFunctionOrMethod()) + SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Typedef); + return Typedef; } @@ -211,6 +214,8 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) { Enum->setInstantiationOfMemberEnum(D); Enum->setAccess(D->getAccess()); Owner->addDecl(SemaRef.Context, Enum); + if (Owner->isFunctionOrMethod()) + SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Enum); Enum->startDefinition(); llvm::SmallVector<Sema::DeclPtrTy, 16> Enumerators; @@ -276,6 +281,8 @@ Decl *TemplateDeclInstantiator::VisitCXXRecordDecl(CXXRecordDecl *D) { Record->setInstantiationOfMemberClass(D); Owner->addDecl(SemaRef.Context, Record); + if (Owner->isFunctionOrMethod()) + SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Record); return Record; } |