Provide the overloaded functions for UnresolvedLookupExpr and

UnresolvedMemberExpr in their constructors, rather than adding them
after the fact. No functionality change.

llvm-svn: 104468
This commit is contained in:
Douglas Gregor 2010-05-23 18:57:34 +00:00
parent 6738a2e39e
commit 30a4f4c757
5 changed files with 45 additions and 35 deletions

View File

@ -1366,11 +1366,14 @@ protected:
OverloadExpr(StmtClass K, QualType T, bool Dependent,
NestedNameSpecifier *Qualifier, SourceRange QRange,
DeclarationName Name, SourceLocation NameLoc,
bool HasTemplateArgs)
bool HasTemplateArgs,
UnresolvedSetIterator Begin, UnresolvedSetIterator End)
: Expr(K, T, Dependent, Dependent),
Name(Name), Qualifier(Qualifier), QualifierRange(QRange),
NameLoc(NameLoc), HasExplicitTemplateArgs(HasTemplateArgs)
{}
{
Results.append(Begin, End);
}
public:
/// Computes whether an unresolved lookup on the given declarations
@ -1394,10 +1397,6 @@ public:
return llvm::PointerIntPair<OverloadExpr*,1>(cast<OverloadExpr>(E), op);
}
void addDecls(UnresolvedSetIterator Begin, UnresolvedSetIterator End) {
Results.append(Begin, End);
}
/// Gets the naming class of this lookup, if any.
CXXRecordDecl *getNamingClass() const;
@ -1405,9 +1404,6 @@ public:
decls_iterator decls_begin() const { return Results.begin(); }
decls_iterator decls_end() const { return Results.end(); }
/// Gets the decls as an unresolved set.
const UnresolvedSetImpl &getDecls() { return Results; }
/// Gets the number of declarations in the unresolved set.
unsigned getNumDecls() const { return Results.size(); }
@ -1478,9 +1474,10 @@ class UnresolvedLookupExpr : public OverloadExpr {
UnresolvedLookupExpr(QualType T, bool Dependent, CXXRecordDecl *NamingClass,
NestedNameSpecifier *Qualifier, SourceRange QRange,
DeclarationName Name, SourceLocation NameLoc,
bool RequiresADL, bool Overloaded, bool HasTemplateArgs)
bool RequiresADL, bool Overloaded, bool HasTemplateArgs,
UnresolvedSetIterator Begin, UnresolvedSetIterator End)
: OverloadExpr(UnresolvedLookupExprClass, T, Dependent, Qualifier, QRange,
Name, NameLoc, HasTemplateArgs),
Name, NameLoc, HasTemplateArgs, Begin, End),
RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass)
{}
@ -1492,11 +1489,14 @@ public:
SourceRange QualifierRange,
DeclarationName Name,
SourceLocation NameLoc,
bool ADL, bool Overloaded) {
bool ADL, bool Overloaded,
UnresolvedSetIterator Begin,
UnresolvedSetIterator End) {
return new(C) UnresolvedLookupExpr(Dependent ? C.DependentTy : C.OverloadTy,
Dependent, NamingClass,
Qualifier, QualifierRange,
Name, NameLoc, ADL, Overloaded, false);
Name, NameLoc, ADL, Overloaded, false,
Begin, End);
}
static UnresolvedLookupExpr *Create(ASTContext &C,
@ -1507,7 +1507,9 @@ public:
DeclarationName Name,
SourceLocation NameLoc,
bool ADL,
const TemplateArgumentListInfo &Args);
const TemplateArgumentListInfo &Args,
UnresolvedSetIterator Begin,
UnresolvedSetIterator End);
/// True if this declaration should be extended by
/// argument-dependent lookup.
@ -2123,7 +2125,8 @@ class UnresolvedMemberExpr : public OverloadExpr {
SourceRange QualifierRange,
DeclarationName Member,
SourceLocation MemberLoc,
const TemplateArgumentListInfo *TemplateArgs);
const TemplateArgumentListInfo *TemplateArgs,
UnresolvedSetIterator Begin, UnresolvedSetIterator End);
public:
static UnresolvedMemberExpr *
@ -2134,7 +2137,8 @@ public:
SourceRange QualifierRange,
DeclarationName Member,
SourceLocation MemberLoc,
const TemplateArgumentListInfo *TemplateArgs);
const TemplateArgumentListInfo *TemplateArgs,
UnresolvedSetIterator Begin, UnresolvedSetIterator End);
/// \brief True if this is an implicit access, i.e. one in which the
/// member being accessed was not written in the source. The source

View File

@ -169,7 +169,9 @@ UnresolvedLookupExpr::Create(ASTContext &C, bool Dependent,
NestedNameSpecifier *Qualifier,
SourceRange QualifierRange, DeclarationName Name,
SourceLocation NameLoc, bool ADL,
const TemplateArgumentListInfo &Args)
const TemplateArgumentListInfo &Args,
UnresolvedSetIterator Begin,
UnresolvedSetIterator End)
{
void *Mem = C.Allocate(sizeof(UnresolvedLookupExpr) +
ExplicitTemplateArgumentList::sizeFor(Args));
@ -179,7 +181,8 @@ UnresolvedLookupExpr::Create(ASTContext &C, bool Dependent,
Qualifier, QualifierRange,
Name, NameLoc, ADL,
/*Overload*/ true,
/*ExplicitTemplateArgs*/ true);
/*ExplicitTemplateArgs*/ true,
Begin, End);
reinterpret_cast<ExplicitTemplateArgumentList*>(ULE+1)->initializeFrom(Args);
@ -709,10 +712,12 @@ UnresolvedMemberExpr::UnresolvedMemberExpr(QualType T, bool Dependent,
SourceRange QualifierRange,
DeclarationName MemberName,
SourceLocation MemberLoc,
const TemplateArgumentListInfo *TemplateArgs)
const TemplateArgumentListInfo *TemplateArgs,
UnresolvedSetIterator Begin,
UnresolvedSetIterator End)
: OverloadExpr(UnresolvedMemberExprClass, T, Dependent,
Qualifier, QualifierRange, MemberName, MemberLoc,
TemplateArgs != 0),
TemplateArgs != 0, Begin, End),
IsArrow(IsArrow), HasUnresolvedUsing(HasUnresolvedUsing),
Base(Base), BaseType(BaseType), OperatorLoc(OperatorLoc) {
if (TemplateArgs)
@ -728,7 +733,9 @@ UnresolvedMemberExpr::Create(ASTContext &C, bool Dependent,
SourceRange QualifierRange,
DeclarationName Member,
SourceLocation MemberLoc,
const TemplateArgumentListInfo *TemplateArgs) {
const TemplateArgumentListInfo *TemplateArgs,
UnresolvedSetIterator Begin,
UnresolvedSetIterator End) {
std::size_t size = sizeof(UnresolvedMemberExpr);
if (TemplateArgs)
size += ExplicitTemplateArgumentList::sizeFor(*TemplateArgs);
@ -738,7 +745,7 @@ UnresolvedMemberExpr::Create(ASTContext &C, bool Dependent,
Dependent ? C.DependentTy : C.OverloadTy,
Dependent, HasUnresolvedUsing, Base, BaseType,
IsArrow, OperatorLoc, Qualifier, QualifierRange,
Member, MemberLoc, TemplateArgs);
Member, MemberLoc, TemplateArgs, Begin, End);
}
CXXRecordDecl *UnresolvedMemberExpr::getNamingClass() const {

View File

@ -1667,8 +1667,8 @@ Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS,
(NestedNameSpecifier*) SS.getScopeRep(),
SS.getRange(),
R.getLookupName(), R.getNameLoc(),
NeedsADL, R.isOverloadedResult());
ULE->addDecls(R.begin(), R.end());
NeedsADL, R.isOverloadedResult(),
R.begin(), R.end());
return Owned(ULE);
}
@ -2729,8 +2729,7 @@ Sema::BuildMemberReferenceExpr(ExprArg Base, QualType BaseExprType,
IsArrow, OpLoc,
Qualifier, SS.getRange(),
MemberName, MemberLoc,
TemplateArgs);
MemExpr->addDecls(R.begin(), R.end());
TemplateArgs, R.begin(), R.end());
return Owned(MemExpr);
}

View File

@ -6285,9 +6285,8 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn,
UnresolvedLookupExpr *Fn
= UnresolvedLookupExpr::Create(Context, /*Dependent*/ true, NamingClass,
0, SourceRange(), OpName, OpLoc,
/*ADL*/ true, IsOverloaded(Fns));
Fn->addDecls(Fns.begin(), Fns.end());
/*ADL*/ true, IsOverloaded(Fns),
Fns.begin(), Fns.end());
input.release();
return Owned(new (Context) CXXOperatorCallExpr(Context, Op, Fn,
&Args[0], NumArgs,
@ -6458,9 +6457,8 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
UnresolvedLookupExpr *Fn
= UnresolvedLookupExpr::Create(Context, /*Dependent*/ true, NamingClass,
0, SourceRange(), OpName, OpLoc,
/*ADL*/ true, IsOverloaded(Fns));
Fn->addDecls(Fns.begin(), Fns.end());
/*ADL*/ true, IsOverloaded(Fns),
Fns.begin(), Fns.end());
return Owned(new (Context) CXXOperatorCallExpr(Context, Op, Fn,
Args, 2,
Context.DependentTy,
@ -6656,7 +6654,9 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
UnresolvedLookupExpr *Fn
= UnresolvedLookupExpr::Create(Context, /*Dependent*/ true, NamingClass,
0, SourceRange(), OpName, LLoc,
/*ADL*/ true, /*Overloaded*/ false);
/*ADL*/ true, /*Overloaded*/ false,
UnresolvedSetIterator(),
UnresolvedSetIterator());
// Can't add any actual overloads yet
Base.release();

View File

@ -1637,8 +1637,8 @@ Sema::OwningExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS,
= UnresolvedLookupExpr::Create(Context, Dependent, R.getNamingClass(),
Qualifier, QualifierRange,
R.getLookupName(), R.getNameLoc(),
RequiresADL, TemplateArgs);
ULE->addDecls(R.begin(), R.end());
RequiresADL, TemplateArgs,
R.begin(), R.end());
return Owned(ULE);
}