aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/AST/Decl.h2
-rw-r--r--include/clang/AST/DeclBase.h4
-rw-r--r--lib/AST/Decl.cpp13
-rw-r--r--lib/AST/DeclBase.cpp15
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp7
-rw-r--r--test/SemaTemplate/instantiate-declref.cpp1
6 files changed, 27 insertions, 15 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index eb38367436..e134aed73d 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -1081,7 +1081,7 @@ public:
/// \brief Whether this declaration declares a type that is
/// dependent, i.e., a type that somehow depends on template
/// parameters.
- bool isDependentType() const;
+ bool isDependentType() const { return isDependentContext(); }
/// @brief Starts the definition of this tag declaration.
///
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index 7d88cf228f..271e59aadc 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -441,6 +441,10 @@ public:
return DeclKind == Decl::Namespace;
}
+ /// \brief Determines whether this context is dependent on a
+ /// template parameter.
+ bool isDependentContext() const;
+
/// isTransparentContext - Determines whether this context is a
/// "transparent" context, meaning that the members declared in this
/// context are semantically declared in the nearest enclosing
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 6c620713f7..063914092e 100644
--- a/lib/AST/Decl.cpp
+++ b/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/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index 071fb79101..ba8f3351c3 100644
--- a/lib/AST/DeclBase.cpp
+++ b/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/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 33eedcec38..39e455a6ec 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/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;
}
diff --git a/test/SemaTemplate/instantiate-declref.cpp b/test/SemaTemplate/instantiate-declref.cpp
index 1a5f216639..e49d330f63 100644
--- a/test/SemaTemplate/instantiate-declref.cpp
+++ b/test/SemaTemplate/instantiate-declref.cpp
@@ -1,5 +1,4 @@
// RUN: clang-cc -fsyntax-only -verify %s
-
namespace N {
struct Outer {
struct Inner {