summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-12-23 00:26:44 +0000
committerDouglas Gregor <dgregor@apple.com>2008-12-23 00:26:44 +0000
commit55297ac4991d0f75b44c4bb6a5dde48076ff827f (patch)
treea41cabf1becbd713a40aa081f8d33b06a5d704b4 /clang/lib/Sema/SemaDeclCXX.cpp
parentd72358cba8f70912b05f210db5184332479ebc1a (diff)
downloadbcm5719-llvm-55297ac4991d0f75b44c4bb6a5dde48076ff827f.tar.gz
bcm5719-llvm-55297ac4991d0f75b44c4bb6a5dde48076ff827f.zip
Don't explicitly represent OverloadedFunctionDecls within
DeclContext. Instead, just keep the list of currently-active declarations and only build the OverloadedFunctionDecl when we absolutely need it. This is a half-step toward eliminating the need to explicitly build OverloadedFunctionDecls that store sets of overloaded functions. This was suggested by Argiris a while back, and it's a good thing for several reasons: first, it eliminates the messy logic that currently tries to keep the OverloadedFunctionDecl in sync with the declarations that are being added. Second, it will (eventually) eliminate the need to allocate memory for overload sets, which could help performance. Finally, it helps set us up for when name lookup can return multiple (possibly ambiguous) results, as can happen with lookup of class members in C++. Next steps: make the IdentifierResolver store overloads as separate entries in its list rather than replacing them with an OverloadedFunctionDecl now, then see how far we can go toward eliminating OverloadedFunctionDecl entirely. llvm-svn: 61357
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp40
1 files changed, 6 insertions, 34 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 8a37bbbe7b4..918fd2ac9a7 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -20,6 +20,7 @@
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Parse/DeclSpec.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Compiler.h"
#include <algorithm> // for std::equal
#include <map>
@@ -844,23 +845,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
CopyConstructor->setParams(&FromParam, 1);
ClassDecl->addedConstructor(Context, CopyConstructor);
- DeclContext::lookup_result Lookup = ClassDecl->lookup(Context, Name);
- if (Lookup.first == Lookup.second
- || (!isa<CXXConstructorDecl>(*Lookup.first) &&
- !isa<OverloadedFunctionDecl>(*Lookup.first)))
- ClassDecl->addDecl(Context, CopyConstructor);
- else {
- OverloadedFunctionDecl *Ovl
- = dyn_cast<OverloadedFunctionDecl>(*Lookup.first);
- if (!Ovl) {
- Ovl = OverloadedFunctionDecl::Create(Context, ClassDecl, Name);
- Ovl->addOverload(cast<CXXConstructorDecl>(*Lookup.first));
- ClassDecl->insert(Context, Ovl);
- }
-
- Ovl->addOverload(CopyConstructor);
- ClassDecl->addDecl(Context, CopyConstructor, false);
- }
+ ClassDecl->addDecl(Context, CopyConstructor);
}
if (!ClassDecl->hasUserDeclaredDestructor()) {
@@ -1470,23 +1455,10 @@ Sema::PerformInitializationByConstructor(QualType ClassType,
DeclarationName ConstructorName
= Context.DeclarationNames.getCXXConstructorName(
Context.getCanonicalType(ClassType.getUnqualifiedType()));
- DeclContext::lookup_const_result Lookup
- = ClassDecl->lookup(Context, ConstructorName);
- if (Lookup.first == Lookup.second)
- /* No constructors */;
- else if (OverloadedFunctionDecl *Constructors
- = dyn_cast<OverloadedFunctionDecl>(*Lookup.first)) {
- for (OverloadedFunctionDecl::function_iterator Con
- = Constructors->function_begin();
- Con != Constructors->function_end(); ++Con) {
- CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(*Con);
- if ((Kind == IK_Direct) ||
- (Kind == IK_Copy && Constructor->isConvertingConstructor()) ||
- (Kind == IK_Default && Constructor->isDefaultConstructor()))
- AddOverloadCandidate(Constructor, Args, NumArgs, CandidateSet);
- }
- } else if (CXXConstructorDecl *Constructor
- = dyn_cast<CXXConstructorDecl>(*Lookup.first)) {
+ DeclContext::lookup_const_iterator Con, ConEnd;
+ for (llvm::tie(Con, ConEnd) = ClassDecl->lookup(Context, ConstructorName);
+ Con != ConEnd; ++Con) {
+ CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(*Con);
if ((Kind == IK_Direct) ||
(Kind == IK_Copy && Constructor->isConvertingConstructor()) ||
(Kind == IK_Default && Constructor->isDefaultConstructor()))
OpenPOWER on IntegriCloud