[cfe-commits] r51772 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/AST/Type.h lib/AST/StmtIterator.cpp

Eli Friedman eli.friedman at gmail.com
Fri May 30 10:01:45 PDT 2008


On Fri, May 30, 2008 at 9:14 AM, Ted Kremenek <kremenek at apple.com> wrote:
> Author: kremenek
> Date: Fri May 30 11:14:41 2008
> New Revision: 51772
>
> URL: http://llvm.org/viewvc/llvm-project?rev=51772&view=rev
> Log:
> Fix some strict-aliasing warnings by using Stmt* instead of Expr* in VariableArrayType, EnumConstantDecl, and VarDecl.

Is it really necessary for StmtIterator to return a "Stmt*&"?  Having
an API like that is just asking for trouble.

> -  const Expr *getInit() const { return Init; }
> -  Expr *getInit() { return Init; }
> -  void setInit(Expr *I) { Init = I; }
> +  const Expr *getInit() const { return (const Expr*) Init; }
> +  Expr *getInit() { return (Expr*) Init; }

cast<Expr*>(Init).  Same thing everywhere else.

> +  void setInit(Expr *I) { Init = (Stmt*) I; }

Unneeded cast.  Same thing everywhere else.

-Eli



More information about the cfe-commits mailing list