summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-12-23 21:05:05 +0000
committerDouglas Gregor <dgregor@apple.com>2008-12-23 21:05:05 +0000
commit8b9ccca5e5f18910c83b7f12754e8bf446e06b27 (patch)
tree436d1fb99b0b8f3a1b83985a1e425917cc5cbbab /clang/lib/Sema/SemaExprCXX.cpp
parent8a35adf3a59e469dee9f63d72ac63261d3ae5289 (diff)
downloadbcm5719-llvm-8b9ccca5e5f18910c83b7f12754e8bf446e06b27.tar.gz
bcm5719-llvm-8b9ccca5e5f18910c83b7f12754e8bf446e06b27.zip
Don't push OverloadedFunctionDecls onto the chain of declarations
attached to an identifier. Instead, all overloaded functions will be pushed into scope, and we'll synthesize an OverloadedFunctionDecl on the fly when we need it. llvm-svn: 61386
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp30
1 files changed, 11 insertions, 19 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index eb2e647f013..9ffa6ae82fb 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -515,26 +515,15 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name,
DeclContext *GlobalCtx = Context.getTranslationUnitDecl();
// Check if this function is already declared.
- IdentifierResolver::iterator I = IdResolver.begin(Name, GlobalCtx,
- /*CheckParent=*/false);
-
- if (I != IdResolver.end()) {
- NamedDecl *Decl = *I;
- if (FunctionDecl *Fn = dyn_cast<FunctionDecl>(Decl)) {
- // The return type fits. This is checked when the function is declared.
- if (Fn->getNumParams() == 1 &&
- Context.getCanonicalType(Fn->getParamDecl(0)->getType()) == Argument)
+ {
+ DeclContext::decl_iterator Alloc, AllocEnd;
+ for (llvm::tie(Alloc, AllocEnd) = GlobalCtx->lookup(Context, Name);
+ Alloc != AllocEnd; ++Alloc) {
+ // FIXME: Do we need to check for default arguments here?
+ FunctionDecl *Func = cast<FunctionDecl>(*Alloc);
+ if (Func->getNumParams() == 1 &&
+ Context.getCanonicalType(Func->getParamDecl(0)->getType()) == Argument)
return;
- } else if(OverloadedFunctionDecl *Ovl =
- dyn_cast<OverloadedFunctionDecl>(Decl)) {
- for (OverloadedFunctionDecl::function_iterator F = Ovl->function_begin(),
- FEnd = Ovl->function_end();
- F != FEnd; ++F) {
- if ((*F)->getNumParams() == 1 &&
- Context.getCanonicalType((*F)->getParamDecl(0)->getType())
- == Argument)
- return;
- }
}
}
@@ -548,6 +537,9 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name,
0, Argument, VarDecl::None, 0, 0);
Alloc->setParams(&Param, 1);
+ // FIXME: Also add this declaration to the IdentifierResolver, but
+ // make sure it is at the end of the chain to coincide with the
+ // global scope.
((DeclContext *)TUScope->getEntity())->addDecl(Context, Alloc);
}
OpenPOWER on IntegriCloud