diff options
Diffstat (limited to 'lib/AST')
-rw-r--r-- | lib/AST/ASTContext.cpp | 1 | ||||
-rw-r--r-- | lib/AST/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lib/AST/DeclBase.cpp | 3 | ||||
-rw-r--r-- | lib/AST/DeclCXX.cpp | 30 | ||||
-rw-r--r-- | lib/AST/DeclSerialization.cpp | 48 | ||||
-rw-r--r-- | lib/AST/DeclTemplate.cpp | 108 | ||||
-rw-r--r-- | lib/AST/Expr.cpp | 1 | ||||
-rw-r--r-- | lib/AST/Type.cpp | 1 |
8 files changed, 161 insertions, 32 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 7892c84f92..7784aed764 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -14,6 +14,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" +#include "clang/AST/DeclTemplate.h" #include "clang/AST/Expr.h" #include "clang/AST/RecordLayout.h" #include "clang/Basic/TargetInfo.h" diff --git a/lib/AST/CMakeLists.txt b/lib/AST/CMakeLists.txt index c49a0eeee5..9687f34be8 100644 --- a/lib/AST/CMakeLists.txt +++ b/lib/AST/CMakeLists.txt @@ -13,6 +13,7 @@ add_clang_library(clangAST DeclGroup.cpp DeclObjC.cpp DeclSerialization.cpp + DeclTemplate.cpp ExprConstant.cpp Expr.cpp ExprCXX.cpp diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 21e1e0ce10..1e3683c857 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -13,8 +13,9 @@ #include "clang/AST/DeclBase.h" #include "clang/AST/Decl.h" -#include "clang/AST/DeclObjC.h" #include "clang/AST/DeclCXX.h" +#include "clang/AST/DeclObjC.h" +#include "clang/AST/DeclTemplate.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Type.h" #include "llvm/ADT/DenseMap.h" diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index 5e1875ab65..6de575411b 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -21,36 +21,6 @@ using namespace clang; // Decl Allocation/Deallocation Method Implementations //===----------------------------------------------------------------------===// -TemplateTypeParmDecl * -TemplateTypeParmDecl::Create(ASTContext &C, DeclContext *DC, - SourceLocation L, IdentifierInfo *Id, - bool Typename) { - return new (C) TemplateTypeParmDecl(DC, L, Id, Typename); -} - -NonTypeTemplateParmDecl * -NonTypeTemplateParmDecl::Create(ASTContext &C, DeclContext *DC, - SourceLocation L, IdentifierInfo *Id, - QualType T, SourceLocation TypeSpecStartLoc) { - return new (C) NonTypeTemplateParmDecl(DC, L, Id, T, TypeSpecStartLoc); -} - -TemplateParameterList::TemplateParameterList(Decl **Params, unsigned NumParams) - : NumParams(NumParams) { - for (unsigned Idx = 0; Idx < NumParams; ++Idx) - begin()[Idx] = Params[Idx]; -} - -TemplateParameterList * -TemplateParameterList::Create(ASTContext &C, Decl **Params, - unsigned NumParams) { - // FIXME: how do I pass in Size to ASTContext::new? - unsigned Size = sizeof(TemplateParameterList) + sizeof(Decl *) * NumParams; - unsigned Align = llvm::AlignOf<TemplateParameterList>::Alignment; - void *Mem = C.Allocate(Size, Align); - return new (Mem) TemplateParameterList(Params, NumParams); -} - CXXRecordDecl::CXXRecordDecl(TagKind TK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id) : RecordDecl(CXXRecord, TK, DC, L, Id), diff --git a/lib/AST/DeclSerialization.cpp b/lib/AST/DeclSerialization.cpp index a10b229fcd..dcb8cda33b 100644 --- a/lib/AST/DeclSerialization.cpp +++ b/lib/AST/DeclSerialization.cpp @@ -14,6 +14,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" +#include "clang/AST/DeclTemplate.h" #include "clang/AST/Expr.h" #include "llvm/Bitcode/Serialize.h" #include "llvm/Bitcode/Deserialize.h" @@ -597,15 +598,60 @@ TypedefDecl* TypedefDecl::CreateImpl(Deserializer& D, ASTContext& C) { //===----------------------------------------------------------------------===// void TemplateTypeParmDecl::EmitImpl(Serializer& S) const { + S.EmitInt(Depth); + S.EmitInt(Position); S.EmitBool(Typename); NamedDecl::EmitInRec(S); } TemplateTypeParmDecl * TemplateTypeParmDecl::CreateImpl(Deserializer& D, ASTContext& C) { + unsigned Depth = D.ReadInt(); + unsigned Position = D.ReadInt(); bool Typename = D.ReadBool(); TemplateTypeParmDecl *decl - = new (C) TemplateTypeParmDecl(0, SourceLocation(), NULL, Typename); + = new (C) TemplateTypeParmDecl(0, SourceLocation(), Depth, Position, + 0, Typename); + decl->NamedDecl::ReadInRec(D, C); + return decl; +} + +//===----------------------------------------------------------------------===// +// NonTypeTemplateParmDecl Serialization. +//===----------------------------------------------------------------------===// +void NonTypeTemplateParmDecl::EmitImpl(Serializer& S) const { + S.EmitInt(Depth); + S.EmitInt(Position); + NamedDecl::Emit(S); +} + +NonTypeTemplateParmDecl* +NonTypeTemplateParmDecl::CreateImpl(Deserializer& D, ASTContext& C) { + unsigned Depth = D.ReadInt(); + unsigned Position = D.ReadInt(); + NonTypeTemplateParmDecl *decl + = new (C) NonTypeTemplateParmDecl(0, SourceLocation(), Depth, Position, + 0, QualType(), SourceLocation()); + decl->NamedDecl::ReadInRec(D, C); + return decl; +} + +//===----------------------------------------------------------------------===// +// TemplateTemplateParmDecl Serialization. +//===----------------------------------------------------------------------===// +void TemplateTemplateParmDecl::EmitImpl(Serializer& S) const { + S.EmitInt(Depth); + S.EmitInt(Position); + NamedDecl::EmitInRec(S); +} + +TemplateTemplateParmDecl* +TemplateTemplateParmDecl::CreateImpl(Deserializer& D, ASTContext& C) { + unsigned Depth = D.ReadInt(); + unsigned Position = D.ReadInt(); + TemplateTemplateParmDecl *decl + = new (C) TemplateTemplateParmDecl(0, SourceLocation(), Depth, Position, + 0, 0); decl->NamedDecl::ReadInRec(D, C); return decl; } diff --git a/lib/AST/DeclTemplate.cpp b/lib/AST/DeclTemplate.cpp new file mode 100644 index 0000000000..08cd5b377d --- /dev/null +++ b/lib/AST/DeclTemplate.cpp @@ -0,0 +1,108 @@ +//===--- DeclCXX.cpp - C++ Declaration AST Node Implementation ------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the C++ related Decl classes for templates. +// +//===----------------------------------------------------------------------===// + +#include "clang/AST/DeclCXX.h" +#include "clang/AST/DeclTemplate.h" +#include "clang/AST/ASTContext.h" +#include "clang/Basic/IdentifierTable.h" +#include "llvm/ADT/STLExtras.h" +using namespace clang; + +//===----------------------------------------------------------------------===// +// TemplateParameterList Implementation +//===----------------------------------------------------------------------===// + +TemplateParameterList::TemplateParameterList(Decl **Params, unsigned NumParams) + : NumParams(NumParams) { + for (unsigned Idx = 0; Idx < NumParams; ++Idx) + begin()[Idx] = Params[Idx]; +} + +TemplateParameterList * +TemplateParameterList::Create(ASTContext &C, Decl **Params, + unsigned NumParams) { + unsigned Size = sizeof(TemplateParameterList) + sizeof(Decl *) * NumParams; + unsigned Align = llvm::AlignOf<TemplateParameterList>::Alignment; + void *Mem = C.Allocate(Size, Align); + return new (Mem) TemplateParameterList(Params, NumParams); +} + +//===----------------------------------------------------------------------===// +// TemplateDecl Implementation +//===----------------------------------------------------------------------===// + +TemplateDecl::~TemplateDecl() { +} + +//===----------------------------------------------------------------------===// +// FunctionTemplateDecl Implementation +//===----------------------------------------------------------------------===// + +FunctionTemplateDecl *FunctionTemplateDecl::Create(ASTContext &C, + DeclContext *DC, + SourceLocation L, + DeclarationName Name, + TemplateParameterList *Params, + NamedDecl *Decl) { + return new (C) FunctionTemplateDecl(DC, L, Name, Params, Decl); +} + +//===----------------------------------------------------------------------===// +// ClassTemplateDecl Implementation +//===----------------------------------------------------------------------===// + +ClassTemplateDecl *ClassTemplateDecl::Create(ASTContext &C, + DeclContext *DC, + SourceLocation L, + DeclarationName Name, + TemplateParameterList *Params, + NamedDecl *Decl) { + return new (C) ClassTemplateDecl(DC, L, Name, Params, Decl); +} + +//===----------------------------------------------------------------------===// +// TemplateTypeParm Allocation/Deallocation Method Implementations +//===----------------------------------------------------------------------===// + +TemplateTypeParmDecl * +TemplateTypeParmDecl::Create(ASTContext &C, DeclContext *DC, + SourceLocation L, unsigned D, unsigned P, + IdentifierInfo *Id, bool Typename) { + return new (C) TemplateTypeParmDecl(DC, L, D, P, Id, Typename); +} + +//===----------------------------------------------------------------------===// +// NonTypeTemplateParmDecl Method Implementations +//===----------------------------------------------------------------------===// + +NonTypeTemplateParmDecl * +NonTypeTemplateParmDecl::Create(ASTContext &C, DeclContext *DC, + SourceLocation L, unsigned D, unsigned P, + IdentifierInfo *Id, QualType T, + SourceLocation TypeSpecStartLoc) { + return new (C) NonTypeTemplateParmDecl(DC, L, D, P, Id, T, + TypeSpecStartLoc); +} + +//===----------------------------------------------------------------------===// +// TemplateTemplateParmDecl Method Implementations +//===----------------------------------------------------------------------===// + +TemplateTemplateParmDecl * +TemplateTemplateParmDecl::Create(ASTContext &C, DeclContext *DC, + SourceLocation L, unsigned D, unsigned P, + IdentifierInfo *Id, + TemplateParameterList *Params) { + return new (C) TemplateTemplateParmDecl(DC, L, D, P, Id, Params); +} + diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 35384d880c..ce13c34012 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -16,6 +16,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclCXX.h" +#include "clang/AST/DeclTemplate.h" #include "clang/AST/RecordLayout.h" #include "clang/AST/StmtVisitor.h" #include "clang/Basic/TargetInfo.h" diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 5d3478b2ea..f39a325e0d 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -15,6 +15,7 @@ #include "clang/AST/Type.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" +#include "clang/AST/DeclTemplate.h" #include "clang/AST/Expr.h" #include "llvm/ADT/StringExtras.h" |