Initial implementation of parsing, semantic analysis, and AST-building
for constructor initializations, e.g.,
class A { };
class B : public A {
int m;
public:
B() : A(), m(17) { };
};
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58749 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index 2170146..9f20ac8 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -109,6 +109,39 @@
return C.getPointerType(ClassTy).withConst();
}
+CXXBaseOrMemberInitializer::
+CXXBaseOrMemberInitializer(QualType BaseType, Expr **Args, unsigned NumArgs)
+ : Args(0), NumArgs(0) {
+ BaseOrMember = reinterpret_cast<uintptr_t>(BaseType.getTypePtr());
+ assert((BaseOrMember & 0x01) == 0 && "Invalid base class type pointer");
+ BaseOrMember |= 0x01;
+
+ if (NumArgs > 0) {
+ this->NumArgs = NumArgs;
+ this->Args = new Expr*[NumArgs];
+ for (unsigned Idx = 0; Idx < NumArgs; ++Idx)
+ this->Args[Idx] = Args[Idx];
+ }
+}
+
+CXXBaseOrMemberInitializer::
+CXXBaseOrMemberInitializer(CXXFieldDecl *Member, Expr **Args, unsigned NumArgs)
+ : Args(0), NumArgs(0) {
+ BaseOrMember = reinterpret_cast<uintptr_t>(Member);
+ assert((BaseOrMember & 0x01) == 0 && "Invalid member pointer");
+
+ if (NumArgs > 0) {
+ this->NumArgs = NumArgs;
+ this->Args = new Expr*[NumArgs];
+ for (unsigned Idx = 0; Idx < NumArgs; ++Idx)
+ this->Args[Idx] = Args[Idx];
+ }
+}
+
+CXXBaseOrMemberInitializer::~CXXBaseOrMemberInitializer() {
+ delete [] Args;
+}
+
CXXConstructorDecl *
CXXConstructorDecl::Create(ASTContext &C, CXXRecordDecl *RD,
SourceLocation L, IdentifierInfo *Id,