Argiris Kirtzidis | 6df1fc0 | 2008-06-09 21:05:31 +0000 | [diff] [blame^] | 1 | //===--- DeclCXX.cpp - C++ Declaration AST Node Implementation ------------===//
|
| 2 | //
|
| 3 | // The LLVM Compiler Infrastructure
|
| 4 | //
|
| 5 | // This file is distributed under the University of Illinois Open Source
|
| 6 | // License. See LICENSE.TXT for details.
|
| 7 | //
|
| 8 | //===----------------------------------------------------------------------===//
|
| 9 | //
|
| 10 | // This file implements the C++ related Decl classes.
|
| 11 | //
|
| 12 | //===----------------------------------------------------------------------===//
|
| 13 |
|
| 14 | #include "clang/AST/DeclCXX.h"
|
| 15 | #include "clang/AST/ASTContext.h"
|
| 16 | using namespace clang;
|
| 17 |
|
| 18 | //===----------------------------------------------------------------------===//
|
| 19 | // Decl Allocation/Deallocation Method Implementations
|
| 20 | //===----------------------------------------------------------------------===//
|
| 21 |
|
| 22 | CXXFieldDecl *CXXFieldDecl::Create(ASTContext &C, CXXRecordDecl *RD,
|
| 23 | SourceLocation L, IdentifierInfo *Id,
|
| 24 | QualType T, Expr *BW) {
|
| 25 | void *Mem = C.getAllocator().Allocate<CXXFieldDecl>();
|
| 26 | return new (Mem) CXXFieldDecl(RD, L, Id, T, BW);
|
| 27 | }
|
| 28 |
|
| 29 | CXXRecordDecl *CXXRecordDecl::Create(ASTContext &C, Kind DK, DeclContext *DC,
|
| 30 | SourceLocation L, IdentifierInfo *Id,
|
| 31 | ScopedDecl *PrevDecl) {
|
| 32 | void *Mem = C.getAllocator().Allocate<CXXRecordDecl>();
|
| 33 | return new (Mem) CXXRecordDecl(DK, DC, L, Id, PrevDecl);
|
| 34 | }
|
| 35 |
|
| 36 | CXXMethodDecl *
|
| 37 | CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD,
|
| 38 | SourceLocation L, IdentifierInfo *Id,
|
| 39 | QualType T, bool isStatic, bool isInline,
|
| 40 | ScopedDecl *PrevDecl) {
|
| 41 | void *Mem = C.getAllocator().Allocate<CXXMethodDecl>();
|
| 42 | return new (Mem) CXXMethodDecl(RD, L, Id, T, isStatic, isInline, PrevDecl);
|
| 43 | }
|
| 44 |
|
| 45 | QualType CXXMethodDecl::getThisType(ASTContext &C) const {
|
| 46 | assert(isInstance() && "No 'this' for static methods!");
|
| 47 | QualType ClassTy = C.getTagDeclType(cast<CXXRecordDecl>(getParent()));
|
| 48 | QualType ThisTy = C.getPointerType(ClassTy);
|
| 49 | ThisTy.addConst();
|
| 50 | return ThisTy;
|
| 51 | }
|
| 52 |
|
| 53 | CXXClassVarDecl *CXXClassVarDecl::Create(ASTContext &C, CXXRecordDecl *RD,
|
| 54 | SourceLocation L, IdentifierInfo *Id,
|
| 55 | QualType T, ScopedDecl *PrevDecl) {
|
| 56 | void *Mem = C.getAllocator().Allocate<CXXClassVarDecl>();
|
| 57 | return new (Mem) CXXClassVarDecl(RD, L, Id, T, PrevDecl);
|
| 58 | }
|