Added new C++ AST Decl subclasses.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52155 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 8d68a58..b5dba10 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -62,7 +62,7 @@
                                    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/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index b5b0283..296304a 100644
--- a/lib/AST/DeclBase.cpp
+++ b/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 @@
   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/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
new file mode 100644
index 0000000..c319191
--- /dev/null
+++ b/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/lib/AST/DeclSerialization.cpp b/lib/AST/DeclSerialization.cpp
index bbc28ab..ca9a152 100644
--- a/lib/AST/DeclSerialization.cpp
+++ b/lib/AST/DeclSerialization.cpp
@@ -384,7 +384,8 @@
   
   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);