[cfe-commits] r89705 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGenCXX/member-expressions.cpp

Eli Friedman eli.friedman at gmail.com
Mon Nov 23 14:47:16 PST 2009


On Mon, Nov 23, 2009 at 1:56 PM, Anders Carlsson <andersca at mac.com> wrote:
> --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Mon Nov 23 15:56:41 2009
> @@ -167,7 +167,14 @@
>
>   Value *VisitArraySubscriptExpr(ArraySubscriptExpr *E);
>   Value *VisitShuffleVectorExpr(ShuffleVectorExpr *E);
> -  Value *VisitMemberExpr(Expr *E)           { return EmitLoadOfLValue(E); }
> +  Value *VisitMemberExpr(MemberExpr *E) {
> +    if (const EnumConstantDecl *EC =
> +          dyn_cast<EnumConstantDecl>(E->getMemberDecl()))
> +      return llvm::ConstantInt::get(VMContext, EC->getInitVal());
> +
> +    return EmitLoadOfLValue(E);
> +  }
> +
>   Value *VisitExtVectorElementExpr(Expr *E) { return EmitLoadOfLValue(E); }
>   Value *VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
>     return EmitLoadOfLValue(E);

In FuncReturningPtr()->EnumConstant, it isn't legal to skip evaluating
FuncReturningPtr().

-Eli




More information about the cfe-commits mailing list