[cfe-commits] r74639 - in /cfe/trunk: include/clang/AST/DeclCXX.h lib/AST/DeclCXX.cpp
Fariborz Jahanian
fjahanian at apple.com
Wed Jul 1 14:05:45 PDT 2009
Author: fjahanian
Date: Wed Jul 1 16:05:43 2009
New Revision: 74639
URL: http://llvm.org/viewvc/llvm-project?rev=74639&view=rev
Log:
Updated CXXConstructorDecl AST node for ctor-initilaizer list.
No change in functionality.
Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/DeclCXX.cpp
Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=74639&r1=74638&r2=74639&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Jul 1 16:05:43 2009
@@ -696,16 +696,23 @@
/// @c !Implicit && ImplicitlyDefined.
bool ImplicitlyDefined : 1;
- /// FIXME: Add support for base and member initializers.
-
+ /// Support for base and member initializers.
+ /// BaseOrMemberInitializers - The arguments used to initialize the base
+ /// or member.
+ CXXBaseOrMemberInitializer **BaseOrMemberInitializers;
+ unsigned NumBaseOrMemberInitializers;
+
CXXConstructorDecl(CXXRecordDecl *RD, SourceLocation L,
DeclarationName N, QualType T,
bool isExplicit, bool isInline, bool isImplicitlyDeclared)
: CXXMethodDecl(CXXConstructor, RD, L, N, T, false, isInline),
- Explicit(isExplicit), ImplicitlyDefined(false) {
+ Explicit(isExplicit), ImplicitlyDefined(false),
+ BaseOrMemberInitializers(0), NumBaseOrMemberInitializers(0) {
setImplicit(isImplicitlyDeclared);
}
-
+
+ ~CXXConstructorDecl() { delete [] BaseOrMemberInitializers; }
+
public:
static CXXConstructorDecl *Create(ASTContext &C, CXXRecordDecl *RD,
SourceLocation L, DeclarationName N,
@@ -721,7 +728,8 @@
/// already been defined.
bool isImplicitlyDefined(ASTContext &C) const {
assert(isThisDeclarationADefinition() &&
- "Can only get the implicit-definition flag once the constructor has been defined");
+ "Can only get the implicit-definition flag once the "
+ "constructor has been defined");
return ImplicitlyDefined;
}
@@ -729,10 +737,40 @@
/// implicitly defined or not.
void setImplicitlyDefined(bool ID) {
assert(isThisDeclarationADefinition() &&
- "Can only set the implicit-definition flag once the constructor has been defined");
+ "Can only set the implicit-definition flag once the constructor "
+ "has been defined");
ImplicitlyDefined = ID;
}
+ /// arg_iterator - Iterates through the member/base initializer list.
+ typedef CXXBaseOrMemberInitializer **arg_iterator;
+
+ /// arg_const_iterator - Iterates through the memberbase initializer list.
+ typedef CXXBaseOrMemberInitializer * const * arg_const_iterator;
+
+ /// begin() - Retrieve an iterator to the first initializer.
+ arg_iterator begin() { return BaseOrMemberInitializers; }
+ /// begin() - Retrieve an iterator to the first initializer.
+ arg_const_iterator begin() const { return BaseOrMemberInitializers; }
+
+ /// end() - Retrieve an iterator past the last initializer.
+ arg_iterator end() {
+ return BaseOrMemberInitializers + NumBaseOrMemberInitializers;
+ }
+ /// end() - Retrieve an iterator past the last initializer.
+ arg_const_iterator end() const {
+ return BaseOrMemberInitializers + NumBaseOrMemberInitializers;
+ }
+
+ /// getNumArgs - Determine the number of arguments used to
+ /// initialize the member or base.
+ unsigned getNumBaseOrMemberInitializers() const {
+ return NumBaseOrMemberInitializers;
+ }
+
+ void setBaseOrMemberInitializers(CXXBaseOrMemberInitializer **Initializers,
+ unsigned NumInitializers);
+
/// isDefaultConstructor - Whether this constructor is a default
/// constructor (C++ [class.ctor]p5), which can be used to
/// default-initialize a class of this type.
Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=74639&r1=74638&r2=74639&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Wed Jul 1 16:05:43 2009
@@ -407,6 +407,19 @@
isImplicitlyDeclared);
}
+void
+CXXConstructorDecl::setBaseOrMemberInitializers(
+ CXXBaseOrMemberInitializer **Initializers,
+ unsigned NumInitializers) {
+ if (NumInitializers > 0) {
+ NumBaseOrMemberInitializers = NumInitializers;
+ BaseOrMemberInitializers =
+ new CXXBaseOrMemberInitializer*[NumInitializers];
+ for (unsigned Idx = 0; Idx < NumInitializers; ++Idx)
+ BaseOrMemberInitializers[Idx] = Initializers[Idx];
+ }
+}
+
CXXConversionDecl *
CXXConversionDecl::Create(ASTContext &C, CXXRecordDecl *RD,
SourceLocation L, DeclarationName N,
More information about the cfe-commits
mailing list