[cfe-commits] r80609 - in /cfe/trunk: lib/Sema/TreeTransform.h test/SemaTemplate/instantiate-expr-2.cpp
Douglas Gregor
dgregor at apple.com
Mon Aug 31 13:00:27 PDT 2009
Author: dgregor
Date: Mon Aug 31 15:00:26 2009
New Revision: 80609
URL: http://llvm.org/viewvc/llvm-project?rev=80609&view=rev
Log:
Implement template instantiation for member operator access.
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaTemplate/instantiate-expr-2.cpp
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=80609&r1=80608&r2=80609&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Mon Aug 31 15:00:26 2009
@@ -837,10 +837,10 @@
OwningExprResult RebuildMemberExpr(ExprArg Base, SourceLocation OpLoc,
bool isArrow, SourceLocation MemberLoc,
NamedDecl *Member) {
- return getSema().ActOnMemberReferenceExpr(/*Scope=*/0, move(Base), OpLoc,
+ return getSema().BuildMemberReferenceExpr(/*Scope=*/0, move(Base), OpLoc,
isArrow? tok::arrow : tok::period,
MemberLoc,
- /*FIXME*/*Member->getIdentifier(),
+ Member->getDeclName(),
/*FIXME?*/Sema::DeclPtrTy::make((Decl*)0));
}
@@ -1435,10 +1435,10 @@
CXXScopeSpec SS;
SS.setRange(QualifierRange);
SS.setScopeRep(Qualifier);
- return getSema().ActOnMemberReferenceExpr(/*Scope=*/0, move(Base), OpLoc,
+ return getSema().BuildMemberReferenceExpr(/*Scope=*/0, move(Base), OpLoc,
isArrow? tok::arrow : tok::period,
MemberLoc,
- /*FIXME*/*Member->getIdentifier(),
+ Member->getDeclName(),
/*FIXME?*/Sema::DeclPtrTy::make((Decl*)0),
&SS);
}
@@ -1459,12 +1459,10 @@
if (Base.isInvalid())
return SemaRef.ExprError();
- assert(Name.getAsIdentifierInfo() &&
- "Cannot transform member references with non-identifier members");
- Base = SemaRef.ActOnMemberReferenceExpr(/*Scope=*/0,
+ Base = SemaRef.BuildMemberReferenceExpr(/*Scope=*/0,
move(Base), OperatorLoc, OpKind,
- MemberLoc,
- *Name.getAsIdentifierInfo(),
+ MemberLoc,
+ Name,
/*FIXME?*/Sema::DeclPtrTy::make((Decl*)0));
SemaRef.ActOnCXXExitMemberScope(0, SS);
return move(Base);
Modified: cfe/trunk/test/SemaTemplate/instantiate-expr-2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-expr-2.cpp?rev=80609&r1=80608&r2=80609&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-expr-2.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-2.cpp Mon Aug 31 15:00:26 2009
@@ -130,3 +130,19 @@
void test_X0(X0<int> x, IntegralConstant<int, sizeof(int)> ic) {
x.f(5,ic);
}
+
+namespace N8 {
+ struct X {
+ X operator+(const X&) const;
+ };
+
+ template<typename T>
+ T test_plus(const T* xp, const T& x, const T& y) {
+ x.operator+(y);
+ return xp->operator+(y);
+ }
+
+ void test_test_plus(X x) {
+ test_plus(&x, x, x);
+ }
+}
More information about the cfe-commits
mailing list