MaybeAddResult(Result(Using->getTargetDecl(), R.Rank, R.Qualifier),
CurContext);
- // Handle each declaration in an overload set separately.
- if (OverloadedFunctionDecl *Ovl
- = dyn_cast<OverloadedFunctionDecl>(R.Declaration)) {
- for (OverloadedFunctionDecl::function_iterator F = Ovl->function_begin(),
- FEnd = Ovl->function_end();
- F != FEnd; ++F)
- MaybeAddResult(Result(*F, R.Rank, R.Qualifier), CurContext);
-
- return;
- }
-
Decl *CanonDecl = R.Declaration->getCanonicalDecl();
unsigned IDNS = CanonDecl->getIdentifierNamespace();
}
bool Sema::isDeclInScope(NamedDecl *&D, DeclContext *Ctx, Scope *S) {
- if (OverloadedFunctionDecl *Ovl = dyn_cast<OverloadedFunctionDecl>(D)) {
- // Look inside the overload set to determine if any of the declarations
- // are in scope. (Possibly) build a new overload set containing only
- // those declarations that are in scope.
- OverloadedFunctionDecl *NewOvl = 0;
- bool FoundInScope = false;
- for (OverloadedFunctionDecl::function_iterator F = Ovl->function_begin(),
- FEnd = Ovl->function_end();
- F != FEnd; ++F) {
- NamedDecl *FD = F->get();
- if (!isDeclInScope(FD, Ctx, S)) {
- if (!NewOvl && F != Ovl->function_begin()) {
- NewOvl = OverloadedFunctionDecl::Create(Context,
- F->get()->getDeclContext(),
- F->get()->getDeclName());
- D = NewOvl;
- for (OverloadedFunctionDecl::function_iterator
- First = Ovl->function_begin();
- First != F; ++First)
- NewOvl->addOverload(*First);
- }
- } else {
- FoundInScope = true;
- if (NewOvl)
- NewOvl->addOverload(*F);
- }
- }
-
- return FoundInScope;
- }
-
return IdResolver.isDeclInScope(D, Ctx, Context, S);
}
///
/// Returns true if there was an error, false otherwise.
bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
- assert(!isa<OverloadedFunctionDecl>(OldD) &&
- "Cannot merge with an overloaded function declaration");
-
// Verify the old decl was also a function.
FunctionDecl *Old = 0;
if (FunctionTemplateDecl *OldFunctionTemplate
if (!PrevDecl)
return 0;
- // FIXME: PrevDecl could be an OverloadedFunctionDecl, in which
- // case we need to check each of the overloaded functions.
if (!PrevDecl->hasLinkage())
return false;
Sema::OwningExprResult
Sema::BuildDeclRefExpr(NamedDecl *D, QualType Ty, SourceLocation Loc,
const CXXScopeSpec *SS) {
- assert(!isa<OverloadedFunctionDecl>(D));
-
if (Context.getCanonicalType(Ty) == Context.UndeducedAutoTy) {
Diag(Loc,
diag::err_auto_variable_cannot_appear_in_own_initializer)
return 0;
}
- OverloadedFunctionDecl *Ovl = dyn_cast<OverloadedFunctionDecl>(D);
- if (!Ovl)
- return 0;
-
- for (OverloadedFunctionDecl::function_iterator F = Ovl->function_begin(),
- FEnd = Ovl->function_end();
- F != FEnd; ++F) {
- if (FunctionTemplateDecl *FuncTmpl = dyn_cast<FunctionTemplateDecl>(*F)) {
- // We've found a function template. Determine whether there are
- // any other function templates we need to bundle together in an
- // OverloadedFunctionDecl
- for (++F; F != FEnd; ++F) {
- if (isa<FunctionTemplateDecl>(*F))
- break;
- }
-
- if (F != FEnd) {
- // Build an overloaded function decl containing only the
- // function templates in Ovl.
- OverloadedFunctionDecl *OvlTemplate
- = OverloadedFunctionDecl::Create(Context,
- Ovl->getDeclContext(),
- Ovl->getDeclName());
- OvlTemplate->addOverload(FuncTmpl);
- OvlTemplate->addOverload(*F);
- for (++F; F != FEnd; ++F) {
- if (isa<FunctionTemplateDecl>(*F))
- OvlTemplate->addOverload(*F);
- }
-
- return OvlTemplate;
- }
-
- return FuncTmpl;
- }
- }
-
return 0;
}
/// this mapping from within the instantiation of X<int>.
NamedDecl *Sema::FindInstantiatedDecl(NamedDecl *D,
const MultiLevelTemplateArgumentList &TemplateArgs) {
- if (OverloadedFunctionDecl *Ovl = dyn_cast<OverloadedFunctionDecl>(D)) {
- // Transform all of the elements of the overloaded function set.
- OverloadedFunctionDecl *Result
- = OverloadedFunctionDecl::Create(Context, CurContext, Ovl->getDeclName());
-
- for (OverloadedFunctionDecl::function_iterator F = Ovl->function_begin(),
- FEnd = Ovl->function_end();
- F != FEnd; ++F) {
- Result->addOverload(
- AnyFunctionDecl::getFromNamedDecl(FindInstantiatedDecl(*F,
- TemplateArgs)));
- }
-
- return Result;
- }
-
DeclContext *ParentDC = D->getDeclContext();
if (isa<ParmVarDecl>(D) || isa<NonTypeTemplateParmDecl>(D) ||
isa<TemplateTypeParmDecl>(D) || isa<TemplateTypeParmDecl>(D) ||