[cfe-commits] r130266 - in /cfe/trunk/lib/Sema: SemaExpr.cpp SemaOverload.cpp

John McCall rjmccall at apple.com
Tue Apr 26 17:36:17 PDT 2011


Author: rjmccall
Date: Tue Apr 26 19:36:17 2011
New Revision: 130266

URL: http://llvm.org/viewvc/llvm-project?rev=130266&view=rev
Log:
FixOverloadedFunctionReference needs to rebuild member accesses of   
instance methods to have bound-member type.

Fixing that broke __unknown_anytype, which I've in turn fixed.


Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=130266&r1=130265&r2=130266&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Apr 26 19:36:17 2011
@@ -10478,16 +10478,17 @@
   Expr *callee = call->getCallee();
 
   enum FnKind {
-    FK_Function,
+    FK_MemberFunction,
     FK_FunctionPointer,
     FK_BlockPointer
   };
 
   FnKind kind;
   QualType type = callee->getType();
-  if (type->isFunctionType()) {
-    assert(isa<CXXMemberCallExpr>(call) || isa<CXXOperatorCallExpr>(call));
-    kind = FK_Function;
+  if (type == S.Context.BoundMemberTy) {
+    assert(isa<CXXMemberCallExpr>(call) || isa<CXXOperatorCallExpr>(call));    
+    kind = FK_MemberFunction;
+    type = Expr::findBoundMemberType(callee);
   } else if (const PointerType *ptr = type->getAs<PointerType>()) {
     type = ptr->getPointeeType();
     kind = FK_FunctionPointer;
@@ -10525,7 +10526,7 @@
 
   // Rebuild the appropriate pointer-to-function type.
   switch (kind) {
-  case FK_Function:
+  case FK_MemberFunction:
     // Nothing to do.
     break;
 
@@ -10594,13 +10595,16 @@
 
   //  - functions
   if (FunctionDecl *fn = dyn_cast<FunctionDecl>(decl)) {
-    if (CXXMethodDecl *method = dyn_cast<CXXMethodDecl>(fn))
-      if (method->isInstance()) valueKind = VK_RValue;
-
     // This is true because FunctionDecls must always have function
     // type, so we can't be resolving the entire thing at once.
     assert(type->isFunctionType());
 
+    if (CXXMethodDecl *method = dyn_cast<CXXMethodDecl>(fn))
+      if (method->isInstance()) {
+        valueKind = VK_RValue;
+        type = S.Context.BoundMemberTy;
+      }
+
     // Function references aren't l-values in C.
     if (!S.getLangOptions().CPlusPlus)
       valueKind = VK_RValue;

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=130266&r1=130265&r2=130266&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Apr 26 19:36:17 2011
@@ -9274,6 +9274,16 @@
     } else
       Base = MemExpr->getBase();
 
+    ExprValueKind valueKind;
+    QualType type;
+    if (cast<CXXMethodDecl>(Fn)->isStatic()) {
+      valueKind = VK_LValue;
+      type = Fn->getType();
+    } else {
+      valueKind = VK_RValue;
+      type = Context.BoundMemberTy;
+    }
+
     return MemberExpr::Create(Context, Base,
                               MemExpr->isArrow(),
                               MemExpr->getQualifierLoc(),
@@ -9281,10 +9291,7 @@
                               Found,
                               MemExpr->getMemberNameInfo(),
                               TemplateArgs,
-                              Fn->getType(),
-                              cast<CXXMethodDecl>(Fn)->isStatic()
-                                ? VK_LValue : VK_RValue,
-                              OK_Ordinary);
+                              type, valueKind, OK_Ordinary);
   }
 
   llvm_unreachable("Invalid reference to overloaded function");





More information about the cfe-commits mailing list