Introduced DeclContext::isDependentContext, which determines whether a
given DeclContext is dependent on type parameters. Use this to
properly determine whether a TagDecl is dependent; previously, we were
missing the case where the TagDecl is a local class of a member
function of a class template (phew!).

Also, make sure that, when we instantiate declarations within a member
function of a class template (or a function template, eventually),
that we add those declarations to the "instantiated locals" map so
that they can be found when instantiating declaration references.

Unfortunately, I was not able to write a useful test for this change,
although the assert() that fires when uncommenting the FIXME'd line in
test/SemaTemplate/instantiate-declref.cpp tells the "experienced user"
that we're now doing the right thing.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72526 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index 071fb79..ba8f335 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -396,6 +396,21 @@
     (*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