summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSean Hunt <scshunt@csclub.uwaterloo.ca>2011-05-01 07:04:31 +0000
committerSean Hunt <scshunt@csclub.uwaterloo.ca>2011-05-01 07:04:31 +0000
commit059ce0d92eb5a7da900ae735dc0a2ea3d64f4b0b (patch)
tree58267829b727c3e865f7dab09b5ac08a42e4fe30 /include
parentccb4ecf9b11d7b652515780253253db976d0447f (diff)
downloadclang-059ce0d92eb5a7da900ae735dc0a2ea3d64f4b0b.tar.gz
clang-059ce0d92eb5a7da900ae735dc0a2ea3d64f4b0b.tar.bz2
clang-059ce0d92eb5a7da900ae735dc0a2ea3d64f4b0b.tar.xz
Fully implement delegating constructors!
As far as I know, this implementation is complete but might be missing a few optimizations. Exceptions and virtual bases are handled correctly. Because I'm an optimist, the web page has appropriately been updated. If I'm wrong, feel free to downgrade its support categories. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130642 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/clang/AST/DeclCXX.h17
-rw-r--r--include/clang/AST/ExprCXX.h3
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td4
-rw-r--r--include/clang/Sema/Initialization.h4
-rw-r--r--include/clang/Sema/Sema.h3
5 files changed, 28 insertions, 3 deletions
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h
index 9d337382a5..8c819e3878 100644
--- a/include/clang/AST/DeclCXX.h
+++ b/include/clang/AST/DeclCXX.h
@@ -1608,6 +1608,23 @@ public:
void setCtorInitializers(CXXCtorInitializer ** initializers) {
CtorInitializers = initializers;
}
+
+ /// isDelegatingConstructor - Whether this constructor is a
+ /// delegating constructor
+ bool isDelegatingConstructor() const {
+ return (getNumCtorInitializers() == 1) &&
+ CtorInitializers[0]->isDelegatingInitializer();
+ }
+
+ /// getTargetConstructor - When this constructor delegates to
+ /// another, retrieve the target
+ CXXConstructorDecl *getTargetConstructor() const {
+ if (isDelegatingConstructor())
+ return CtorInitializers[0]->getTargetConstructor();
+ else
+ return 0;
+ }
+
/// isDefaultConstructor - Whether this constructor is a default
/// constructor (C++ [class.ctor]p5), which can be used to
/// default-initialize a class of this type.
diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h
index 0040f13cd3..a970579737 100644
--- a/include/clang/AST/ExprCXX.h
+++ b/include/clang/AST/ExprCXX.h
@@ -780,7 +780,8 @@ public:
enum ConstructionKind {
CK_Complete,
CK_NonVirtualBase,
- CK_VirtualBase
+ CK_VirtualBase,
+ CK_Delegating
};
private:
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 04ff97c155..b05e13313e 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1008,6 +1008,10 @@ def err_delegation_unimplemented : Error<
"delegating constructors are not fully implemented">;
def err_delegating_initializer_alone : Error<
"an initializer for a delegating constructor must appear alone">;
+def err_delegating_ctor_loop : Error<
+ "constructor %0 delegates to itself (possibly indirectly)">;
+def err_delegating_codegen_not_implemented : Error<
+ "code generation for delegating constructors not implemented">;
// C++0x range-based for loop
def err_for_range_decl_must_be_var : Error<
diff --git a/include/clang/Sema/Initialization.h b/include/clang/Sema/Initialization.h
index d3865ce314..e83e5c0ccf 100644
--- a/include/clang/Sema/Initialization.h
+++ b/include/clang/Sema/Initialization.h
@@ -65,7 +65,7 @@ public:
/// \brief The entity being initialized is a base member subobject.
EK_Base,
/// \brief The initialization is being done by a delegating constructor.
- EK_Delegation,
+ EK_Delegating,
/// \brief The entity being initialized is an element of a vector.
/// or vector.
EK_VectorElement,
@@ -215,7 +215,7 @@ public:
/// \brief Create the initialization entity for a delegated constructor.
static InitializedEntity InitializeDelegation(QualType Type) {
- return InitializedEntity(EK_Delegation, SourceLocation(), Type);
+ return InitializedEntity(EK_Delegating, SourceLocation(), Type);
}
/// \brief Create the initialization entity for a member subobject.
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h
index 0744ced9e9..7dc42b9c56 100644
--- a/include/clang/Sema/Sema.h
+++ b/include/clang/Sema/Sema.h
@@ -3072,6 +3072,9 @@ public:
SourceLocation LParenLoc,
CXXRecordDecl *ClassDecl);
+ bool SetDelegatingInitializer(CXXConstructorDecl *Constructor,
+ CXXCtorInitializer *Initializer);
+
bool SetCtorInitializers(CXXConstructorDecl *Constructor,
CXXCtorInitializer **Initializers,
unsigned NumInitializers, bool AnyErrors);