summaryrefslogtreecommitdiffstats
path: root/clang/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
commit26897467058db53eb3446af4904c7dbb80897ada (patch)
tree1d550f16f7b26845bded821246dd94c7681124d2 /clang/lib/Sema/SemaTemplateInstantiate.cpp
parentf24fcff65e3b4c1f6090c7845be0cfee8bbd15d0 (diff)
downloadbcm5719-llvm-26897467058db53eb3446af4904c7dbb80897ada.tar.gz
bcm5719-llvm-26897467058db53eb3446af4904c7dbb80897ada.zip
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? llvm-svn: 66662
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiate.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 21694b2e739..d630e801b02 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/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.
OpenPOWER on IntegriCloud