aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateInstantiate.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-03-11 16:48:53 +0000
committerDouglas Gregor <dgregor@apple.com>2009-03-11 16:48:53 +0000
commit4fdf1faedbca40787fd277a6fbd5061fd69b2708 (patch)
tree008da53407dbd3facf3ffa4d9c8b1558b2617228 /lib/Sema/SemaTemplateInstantiate.cpp
parent511d7aba3b12853fdb88729a0313b80a60eab8ad (diff)
Add basic, hackish support for instantiation of typedefs in a class
template. More importantly, start to sort out the issues regarding complete types and nested-name-specifiers, especially the question of: when do we instantiate a class template specialization that occurs to the left of a '::' in a nested-name-specifier? git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66662 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r--lib/Sema/SemaTemplateInstantiate.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 21694b2e73..d630e801b0 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -655,13 +655,44 @@ Sema::InstantiateClassTemplateSpecialization(
// Start the definition of this instantiation.
ClassTemplateSpec->startDefinition();
- // FIXME: Create the injected-class-name for the
- // instantiation. Should this be a typedef or something like it?
// Instantiate the base class specifiers.
if (InstantiateBaseSpecifiers(ClassTemplateSpec, Template))
Invalid = true;
+ // FIXME: Create the injected-class-name for the
+ // instantiation. Should this be a typedef or something like it?
+
+ RecordDecl *Pattern = Template->getTemplatedDecl();
+
+ for (RecordDecl::decl_iterator Member = Pattern->decls_begin(),
+ MemberEnd = Pattern->decls_end();
+ Member != MemberEnd; ++Member) {
+ if (TypedefDecl *Typedef = dyn_cast<TypedefDecl>(*Member)) {
+ // FIXME: Simplified instantiation of typedefs needs to be made
+ // "real".
+ QualType T = Typedef->getUnderlyingType();
+ if (T->isDependentType()) {
+ T = InstantiateType(T, ClassTemplateSpec->getTemplateArgs(),
+ ClassTemplateSpec->getNumTemplateArgs(),
+ Typedef->getLocation(),
+ Typedef->getDeclName());
+ if (T.isNull()) {
+ Invalid = true;
+ T = Context.IntTy;
+ }
+ }
+
+ // Create the new typedef
+ TypedefDecl *New
+ = TypedefDecl::Create(Context, ClassTemplateSpec,
+ Typedef->getLocation(),
+ Typedef->getIdentifier(),
+ T);
+ ClassTemplateSpec->addDecl(New);
+ }
+ }
+
// FIXME: Instantiate all of the members.
// Add any implicitly-declared members that we might need.