diff options
Diffstat (limited to 'clang/lib/AST')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 2 | ||||
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 8 | ||||
-rw-r--r-- | clang/lib/AST/DeclCXX.cpp | 58 | ||||
-rw-r--r-- | clang/lib/AST/DeclSerialization.cpp | 3 |
4 files changed, 69 insertions, 2 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 8d68a58f8c1..b5dba1029b8 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -62,7 +62,7 @@ FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC, StorageClass S, bool isInline, ScopedDecl *PrevDecl) { void *Mem = C.getAllocator().Allocate<FunctionDecl>(); - return new (Mem) FunctionDecl(DC, L, Id, T, S, isInline, PrevDecl); + return new (Mem) FunctionDecl(Function, DC, L, Id, T, S, isInline, PrevDecl); } FieldDecl *FieldDecl::Create(ASTContext &C, SourceLocation L, diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index b5b028320df..296304a66dd 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "clang/AST/DeclBase.h" +#include "clang/AST/DeclCXX.h" #include "clang/AST/ASTContext.h" #include "llvm/ADT/DenseMap.h" using namespace clang; @@ -206,6 +207,13 @@ void Decl::addDeclKind(Kind k) { case LinkageSpec: nLinkageSpecDecl++; break; case FileScopeAsm: nFileScopeAsmDecl++; break; case TranslationUnit: break; + + // FIXME: Statistics for C++ decls. + case CXXField: + case CXXStruct: case CXXUnion: case CXXClass: + case CXXMethod: + case CXXClassVar: + break; } } diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp new file mode 100644 index 00000000000..c319191bae6 --- /dev/null +++ b/clang/lib/AST/DeclCXX.cpp @@ -0,0 +1,58 @@ +//===--- 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.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/ASTContext.h"
+using namespace clang;
+
+//===----------------------------------------------------------------------===//
+// Decl Allocation/Deallocation Method Implementations
+//===----------------------------------------------------------------------===//
+
+CXXFieldDecl *CXXFieldDecl::Create(ASTContext &C, CXXRecordDecl *RD,
+ SourceLocation L, IdentifierInfo *Id,
+ QualType T, Expr *BW) {
+ void *Mem = C.getAllocator().Allocate<CXXFieldDecl>();
+ return new (Mem) CXXFieldDecl(RD, L, Id, T, BW);
+}
+
+CXXRecordDecl *CXXRecordDecl::Create(ASTContext &C, Kind DK, DeclContext *DC,
+ SourceLocation L, IdentifierInfo *Id,
+ ScopedDecl *PrevDecl) {
+ void *Mem = C.getAllocator().Allocate<CXXRecordDecl>();
+ return new (Mem) CXXRecordDecl(DK, DC, L, Id, PrevDecl);
+}
+
+CXXMethodDecl *
+CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD,
+ SourceLocation L, IdentifierInfo *Id,
+ QualType T, bool isStatic, bool isInline,
+ ScopedDecl *PrevDecl) {
+ void *Mem = C.getAllocator().Allocate<CXXMethodDecl>();
+ return new (Mem) CXXMethodDecl(RD, L, Id, T, isStatic, isInline, PrevDecl);
+}
+
+QualType CXXMethodDecl::getThisType(ASTContext &C) const {
+ assert(isInstance() && "No 'this' for static methods!");
+ QualType ClassTy = C.getTagDeclType(cast<CXXRecordDecl>(getParent()));
+ QualType ThisTy = C.getPointerType(ClassTy);
+ ThisTy.addConst();
+ return ThisTy;
+}
+
+CXXClassVarDecl *CXXClassVarDecl::Create(ASTContext &C, CXXRecordDecl *RD,
+ SourceLocation L, IdentifierInfo *Id,
+ QualType T, ScopedDecl *PrevDecl) {
+ void *Mem = C.getAllocator().Allocate<CXXClassVarDecl>();
+ return new (Mem) CXXClassVarDecl(RD, L, Id, T, PrevDecl);
+}
diff --git a/clang/lib/AST/DeclSerialization.cpp b/clang/lib/AST/DeclSerialization.cpp index bbc28ab6d78..ca9a15224f6 100644 --- a/clang/lib/AST/DeclSerialization.cpp +++ b/clang/lib/AST/DeclSerialization.cpp @@ -384,7 +384,8 @@ FunctionDecl* FunctionDecl::CreateImpl(Deserializer& D, ASTContext& C) { void *Mem = C.getAllocator().Allocate<FunctionDecl>(); FunctionDecl* decl = new (Mem) - FunctionDecl(0, SourceLocation(), NULL, QualType(), SClass, IsInline, 0); + FunctionDecl(Function, 0, SourceLocation(), NULL, + QualType(), SClass, IsInline, 0); decl->ValueDecl::ReadInRec(D, C); D.ReadPtr(decl->DeclChain); |