[cfe-commits] r104469 - in /cfe/trunk: include/clang/AST/ExprCXX.h include/clang/AST/UnresolvedSet.h lib/AST/ExprCXX.cpp
Douglas Gregor
dgregor at apple.com
Sun May 23 12:36:41 PDT 2010
Author: dgregor
Date: Sun May 23 14:36:40 2010
New Revision: 104469
URL: http://llvm.org/viewvc/llvm-project?rev=104469&view=rev
Log:
Move OverloadExpr over to a ASTContext-allocated pointer for its
storage, rather than an UnresolvedSet.
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/UnresolvedSet.h
cfe/trunk/lib/AST/ExprCXX.cpp
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=104469&r1=104468&r2=104469&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Sun May 23 14:36:40 2010
@@ -1345,7 +1345,9 @@
/// The results. These are undesugared, which is to say, they may
/// include UsingShadowDecls. Access is relative to the naming
/// class.
- UnresolvedSet<4> Results;
+ // FIXME: Allocate this data after the OverloadExpr subclass.
+ DeclAccessPair *Results;
+ unsigned NumResults;
/// The common name of these declarations.
DeclarationName Name;
@@ -1363,17 +1365,11 @@
bool HasExplicitTemplateArgs;
protected:
- OverloadExpr(StmtClass K, QualType T, bool Dependent,
+ OverloadExpr(StmtClass K, ASTContext &C, QualType T, bool Dependent,
NestedNameSpecifier *Qualifier, SourceRange QRange,
DeclarationName Name, SourceLocation NameLoc,
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);
- }
+ UnresolvedSetIterator Begin, UnresolvedSetIterator End);
public:
/// Computes whether an unresolved lookup on the given declarations
@@ -1401,11 +1397,13 @@
CXXRecordDecl *getNamingClass() const;
typedef UnresolvedSetImpl::iterator decls_iterator;
- decls_iterator decls_begin() const { return Results.begin(); }
- decls_iterator decls_end() const { return Results.end(); }
+ decls_iterator decls_begin() const { return UnresolvedSetIterator(Results); }
+ decls_iterator decls_end() const {
+ return UnresolvedSetIterator(Results + NumResults);
+ }
/// Gets the number of declarations in the unresolved set.
- unsigned getNumDecls() const { return Results.size(); }
+ unsigned getNumDecls() const { return NumResults; }
/// Gets the name looked up.
DeclarationName getName() const { return Name; }
@@ -1471,13 +1469,14 @@
/// against the qualified-lookup bits.
CXXRecordDecl *NamingClass;
- UnresolvedLookupExpr(QualType T, bool Dependent, CXXRecordDecl *NamingClass,
+ UnresolvedLookupExpr(ASTContext &C, QualType T, bool Dependent,
+ CXXRecordDecl *NamingClass,
NestedNameSpecifier *Qualifier, SourceRange QRange,
DeclarationName Name, SourceLocation NameLoc,
bool RequiresADL, bool Overloaded, bool HasTemplateArgs,
UnresolvedSetIterator Begin, UnresolvedSetIterator End)
- : OverloadExpr(UnresolvedLookupExprClass, T, Dependent, Qualifier, QRange,
- Name, NameLoc, HasTemplateArgs, Begin, End),
+ : OverloadExpr(UnresolvedLookupExprClass, C, T, Dependent, Qualifier,
+ QRange, Name, NameLoc, HasTemplateArgs, Begin, End),
RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass)
{}
@@ -1492,7 +1491,8 @@
bool ADL, bool Overloaded,
UnresolvedSetIterator Begin,
UnresolvedSetIterator End) {
- return new(C) UnresolvedLookupExpr(Dependent ? C.DependentTy : C.OverloadTy,
+ return new(C) UnresolvedLookupExpr(C,
+ Dependent ? C.DependentTy : C.OverloadTy,
Dependent, NamingClass,
Qualifier, QualifierRange,
Name, NameLoc, ADL, Overloaded, false,
@@ -2117,7 +2117,7 @@
/// \brief The location of the '->' or '.' operator.
SourceLocation OperatorLoc;
- UnresolvedMemberExpr(QualType T, bool Dependent,
+ UnresolvedMemberExpr(ASTContext &C, QualType T, bool Dependent,
bool HasUnresolvedUsing,
Expr *Base, QualType BaseType, bool IsArrow,
SourceLocation OperatorLoc,
Modified: cfe/trunk/include/clang/AST/UnresolvedSet.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/UnresolvedSet.h?rev=104469&r1=104468&r2=104469&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/UnresolvedSet.h (original)
+++ cfe/trunk/include/clang/AST/UnresolvedSet.h Sun May 23 14:36:40 2010
@@ -31,9 +31,13 @@
IteratorTy ir;
friend class UnresolvedSetImpl;
+ friend class OverloadExpr;
explicit UnresolvedSetIterator(DeclsTy::iterator ir) : ir(ir) {}
explicit UnresolvedSetIterator(DeclsTy::const_iterator ir) :
ir(const_cast<DeclsTy::iterator>(ir)) {}
+
+ IteratorTy getIterator() const { return ir; }
+
public:
UnresolvedSetIterator() {}
@@ -81,9 +85,7 @@
bool operator>(const UnresolvedSetIterator &o) const { return ir > o.ir; }
};
-/// UnresolvedSet - A set of unresolved declarations. This is needed
-/// in a lot of places, but isn't really worth breaking into its own
-/// header right now.
+/// UnresolvedSet - A set of unresolved declarations.
class UnresolvedSetImpl {
typedef UnresolvedSetIterator::DeclsTy DeclsTy;
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=104469&r1=104468&r2=104469&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Sun May 23 14:36:40 2010
@@ -176,7 +176,8 @@
void *Mem = C.Allocate(sizeof(UnresolvedLookupExpr) +
ExplicitTemplateArgumentList::sizeFor(Args));
UnresolvedLookupExpr *ULE
- = new (Mem) UnresolvedLookupExpr(Dependent ? C.DependentTy : C.OverloadTy,
+ = new (Mem) UnresolvedLookupExpr(C,
+ Dependent ? C.DependentTy : C.OverloadTy,
Dependent, NamingClass,
Qualifier, QualifierRange,
Name, NameLoc, ADL,
@@ -189,6 +190,26 @@
return ULE;
}
+OverloadExpr::OverloadExpr(StmtClass K, ASTContext &C, QualType T,
+ bool Dependent, NestedNameSpecifier *Qualifier,
+ SourceRange QRange, DeclarationName Name,
+ SourceLocation NameLoc, bool HasTemplateArgs,
+ UnresolvedSetIterator Begin,
+ UnresolvedSetIterator End)
+ : Expr(K, T, Dependent, Dependent),
+ Results(0), NumResults(End - Begin), Name(Name), Qualifier(Qualifier),
+ QualifierRange(QRange), NameLoc(NameLoc),
+ HasExplicitTemplateArgs(HasTemplateArgs)
+{
+ if (NumResults) {
+ Results = static_cast<DeclAccessPair *>(
+ C.Allocate(sizeof(DeclAccessPair) * NumResults,
+ llvm::alignof<DeclAccessPair>()));
+ memcpy(Results, &*Begin.getIterator(),
+ (End - Begin) * sizeof(DeclAccessPair));
+ }
+}
+
bool OverloadExpr::ComputeDependence(UnresolvedSetIterator Begin,
UnresolvedSetIterator End,
const TemplateArgumentListInfo *Args) {
@@ -703,7 +724,8 @@
return child_iterator(&Base + 1);
}
-UnresolvedMemberExpr::UnresolvedMemberExpr(QualType T, bool Dependent,
+UnresolvedMemberExpr::UnresolvedMemberExpr(ASTContext &C, QualType T,
+ bool Dependent,
bool HasUnresolvedUsing,
Expr *Base, QualType BaseType,
bool IsArrow,
@@ -715,7 +737,7 @@
const TemplateArgumentListInfo *TemplateArgs,
UnresolvedSetIterator Begin,
UnresolvedSetIterator End)
- : OverloadExpr(UnresolvedMemberExprClass, T, Dependent,
+ : OverloadExpr(UnresolvedMemberExprClass, C, T, Dependent,
Qualifier, QualifierRange, MemberName, MemberLoc,
TemplateArgs != 0, Begin, End),
IsArrow(IsArrow), HasUnresolvedUsing(HasUnresolvedUsing),
@@ -741,7 +763,7 @@
size += ExplicitTemplateArgumentList::sizeFor(*TemplateArgs);
void *Mem = C.Allocate(size, llvm::alignof<UnresolvedMemberExpr>());
- return new (Mem) UnresolvedMemberExpr(
+ return new (Mem) UnresolvedMemberExpr(C,
Dependent ? C.DependentTy : C.OverloadTy,
Dependent, HasUnresolvedUsing, Base, BaseType,
IsArrow, OperatorLoc, Qualifier, QualifierRange,
More information about the cfe-commits
mailing list