]> granicus.if.org Git - clang/commitdiff
Implement template instantiation for member operator access.
authorDouglas Gregor <dgregor@apple.com>
Mon, 31 Aug 2009 20:00:26 +0000 (20:00 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 31 Aug 2009 20:00:26 +0000 (20:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80609 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/TreeTransform.h
test/SemaTemplate/instantiate-expr-2.cpp

index 8aabad575a2c3794517dd944f20aa640da246cdf..deb54115a5830abc3e71c35af5e2e9ef7de05053 100644 (file)
@@ -837,10 +837,10 @@ public:
   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 @@ public:
     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 @@ public:
     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);
index 80f403ed56fe7c552873b2a89a01f723bc883514..2c3ccb06e4205b7271a812da8cd899a00cf9438a 100644 (file)
@@ -130,3 +130,19 @@ struct X0 {
 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);
+  }
+}