瀏覽代碼

Now that DeclRefExpr accepts a NamedDecl, use a DeclRefExpr for when a CXXFieldDecl is referenced inside a method.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58000 91177308-0d34-0410-b5e6-96231b3b80d8
Argyrios Kyrtzidis 17 年之前
父節點
當前提交
90b7bc6751
共有 2 個文件被更改,包括 2 次插入5 次删除
  1. 1 1
      lib/AST/Expr.cpp
  2. 1 4
      lib/Sema/SemaExpr.cpp

+ 1 - 1
lib/AST/Expr.cpp

@@ -325,7 +325,7 @@ bool Expr::hasLocalSideEffect() const {
 /// DeclCanBeLvalue - Determine whether the given declaration can be
 /// DeclCanBeLvalue - Determine whether the given declaration can be
 /// an lvalue. This is a helper routine for isLvalue.
 /// an lvalue. This is a helper routine for isLvalue.
 static bool DeclCanBeLvalue(const NamedDecl *Decl, ASTContext &Ctx) {
 static bool DeclCanBeLvalue(const NamedDecl *Decl, ASTContext &Ctx) {
-  return isa<VarDecl>(Decl) || 
+  return isa<VarDecl>(Decl) || isa<CXXFieldDecl>(Decl) ||
     // C++ 3.10p2: An lvalue refers to an object or function.
     // C++ 3.10p2: An lvalue refers to an object or function.
     (Ctx.getLangOptions().CPlusPlus &&
     (Ctx.getLangOptions().CPlusPlus &&
      (isa<FunctionDecl>(Decl) || isa<OverloadedFunctionDecl>(Decl)));
      (isa<FunctionDecl>(Decl) || isa<OverloadedFunctionDecl>(Decl)));

+ 1 - 4
lib/Sema/SemaExpr.cpp

@@ -402,10 +402,7 @@ Sema::ExprResult Sema::ActOnIdentifierExpr(Scope *S, SourceLocation Loc,
       if (FD->isInvalidDecl())
       if (FD->isInvalidDecl())
         return true;
         return true;
 
 
-      // FIXME: Use DeclRefExpr or a new Expr for a direct CXXField reference.
-      ExprResult ThisExpr = ActOnCXXThis(SourceLocation());
-      return new MemberExpr(static_cast<Expr*>(ThisExpr.Val),
-                            true, FD, Loc, FD->getType());
+      return new DeclRefExpr(FD, FD->getType(), Loc);
     }
     }
 
 
     return Diag(Loc, diag::err_invalid_non_static_member_use, FD->getName());
     return Diag(Loc, diag::err_invalid_non_static_member_use, FD->getName());