summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-12-15 21:24:18 +0000
committerDouglas Gregor <dgregor@apple.com>2008-12-15 21:24:18 +0000
commit1349b457eee7240bb8022483db59d7edc87d6b47 (patch)
treeed4883aeac904e97986d7c8aa05d1e3cb9486eab /clang/lib/Sema/SemaOverload.cpp
parent1c731fa86f493d08958a06a90e5853b3580f40a4 (diff)
downloadbcm5719-llvm-1349b457eee7240bb8022483db59d7edc87d6b47.tar.gz
bcm5719-llvm-1349b457eee7240bb8022483db59d7edc87d6b47.zip
Place constructors and destructors into the DeclContext of the class,
just like all other members, and remove the special variables in CXXRecordDecl to store them. This eliminates a lot of special-case code for constructors and destructors, including ActOnConstructor/ActOnDeclarator and special lookup rules in LookupDecl. The result is far more uniform and manageable. Diagnose the redeclaration of member functions. llvm-svn: 61048
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r--clang/lib/Sema/SemaOverload.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 4bfe0c4dab2..5e3ec3f4bbd 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -953,11 +953,25 @@ bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType,
// that class. The argument list is the expression-list within
// the parentheses of the initializer.
CXXRecordDecl *ToRecordDecl = ToRecordType->getDecl();
- const OverloadedFunctionDecl *Constructors = ToRecordDecl->getConstructors();
- for (OverloadedFunctionDecl::function_const_iterator func
- = Constructors->function_begin();
- func != Constructors->function_end(); ++func) {
- CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(*func);
+ DeclarationName ConstructorName
+ = Context.DeclarationNames.getCXXConstructorName(
+ Context.getCanonicalType(ToType));
+ DeclContext::lookup_result Lookup
+ = ToRecordDecl->lookup(Context, ConstructorName);
+ if (Lookup.first == Lookup.second)
+ /* No constructors. FIXME: Implicit copy constructor? */;
+ else if (OverloadedFunctionDecl *Constructors
+ = dyn_cast<OverloadedFunctionDecl>(*Lookup.first)) {
+ for (OverloadedFunctionDecl::function_const_iterator func
+ = Constructors->function_begin();
+ func != Constructors->function_end(); ++func) {
+ CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(*func);
+ if (Constructor->isConvertingConstructor())
+ AddOverloadCandidate(Constructor, &From, 1, CandidateSet,
+ /*SuppressUserConversions=*/true);
+ }
+ } else if (CXXConstructorDecl *Constructor
+ = dyn_cast<CXXConstructorDecl>(*Lookup.first)) {
if (Constructor->isConvertingConstructor())
AddOverloadCandidate(Constructor, &From, 1, CandidateSet,
/*SuppressUserConversions=*/true);
OpenPOWER on IntegriCloud