diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-02-17 01:05:43 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-02-17 01:05:43 +0000 |
commit | 264ec4f2377624a9ef3418d40de67b7579b5c5f5 (patch) | |
tree | bedec96157245add7a32443c991ec4b06740ff9b /clang/lib/AST/DeclTemplate.cpp | |
parent | 3c50922ea02b8f23fa306c7e695f9eaefe8b602a (diff) | |
download | bcm5719-llvm-264ec4f2377624a9ef3418d40de67b7579b5c5f5.tar.gz bcm5719-llvm-264ec4f2377624a9ef3418d40de67b7579b5c5f5.zip |
Added ClassTemplateSpecializationDecl, which is a subclass of
CXXRecordDecl that is used to represent class template
specializations. These are canonical declarations that can refer to
either an actual class template specialization in the code, e.g.,
template<> class vector<bool> { };
or to a template instantiation. However, neither of these features is
actually implemented yet, so really we're just using (and uniqing) the
declarations to make sure that, e.g., A<int> is a different type from
A<float>. Note that we carefully distinguish between what the user
wrote in the source code (e.g., "A<FLOAT>") and the semantic entity it
represents (e.g., "A<float, int>"); the former is in the sugared Type,
the latter is an actual Decl.
llvm-svn: 64716
Diffstat (limited to 'clang/lib/AST/DeclTemplate.cpp')
-rw-r--r-- | clang/lib/AST/DeclTemplate.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp index dccb8df0757..81ef3ab70e4 100644 --- a/clang/lib/AST/DeclTemplate.cpp +++ b/clang/lib/AST/DeclTemplate.cpp @@ -143,3 +143,39 @@ SourceLocation TemplateTemplateParmDecl::getDefaultArgumentLoc() const { return DefaultArgument? DefaultArgument->getSourceRange().getBegin() : SourceLocation(); } + +//===----------------------------------------------------------------------===// +// ClassTemplateSpecializationDecl Implementation +//===----------------------------------------------------------------------===// +ClassTemplateSpecializationDecl:: +ClassTemplateSpecializationDecl(DeclContext *DC, SourceLocation L, + ClassTemplateDecl *SpecializedTemplate, + TemplateArgument *TemplateArgs, + unsigned NumTemplateArgs) + : CXXRecordDecl(ClassTemplateSpecialization, + SpecializedTemplate->getTemplatedDecl()->getTagKind(), + DC, L, + // FIXME: Should we use DeclarationName for the name of + // class template specializations? + SpecializedTemplate->getIdentifier()), + SpecializedTemplate(SpecializedTemplate), + NumTemplateArgs(NumTemplateArgs) { + TemplateArgument *Arg = reinterpret_cast<TemplateArgument *>(this + 1); + for (unsigned ArgIdx = 0; ArgIdx < NumTemplateArgs; ++ArgIdx, ++Arg) + *Arg = TemplateArgs[ArgIdx]; +} + +ClassTemplateSpecializationDecl * +ClassTemplateSpecializationDecl::Create(ASTContext &Context, + DeclContext *DC, SourceLocation L, + ClassTemplateDecl *SpecializedTemplate, + TemplateArgument *TemplateArgs, + unsigned NumTemplateArgs) { + unsigned Size = sizeof(ClassTemplateSpecializationDecl) + + sizeof(TemplateArgument) * NumTemplateArgs; + unsigned Align = llvm::AlignOf<ClassTemplateSpecializationDecl>::Alignment; + void *Mem = Context.Allocate(Size, Align); + return new (Mem) ClassTemplateSpecializationDecl(DC, L, SpecializedTemplate, + TemplateArgs, + NumTemplateArgs); +} |