[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-commits
Subject:    Re: [cfe-commits] r51772 - in /cfe/trunk: include/clang/AST/Decl.h
From:       "Eli Friedman" <eli.friedman () gmail ! com>
Date:       2008-05-30 18:52:16
Message-ID: f5aa3e9b0805301152h42ba012ia2d0ae4cf91a26e0 () mail ! gmail ! com
[Download RAW message or body]

On Fri, May 30, 2008 at 11:25 AM, Ted Kremenek <kremenek@apple.com> wrote:
>
> On May 30, 2008, at 10:01 AM, Eli Friedman wrote:
>
>>> 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.
>
> Originally it just returned Stmt*, but having Stmt*& proved to be extremely
> useful for the Objective-C rewriter.  I agree that it can be a source of
> problems if a client is not careful.

Mmm, not sure what to say.

>>> -  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.
>
> Using cast<Expr*> requires Decl.h including Expr.h (which is problematic to
> do since Expr.h includes Decl.h).  Use cast<Expr> and you will see that
> clang doesn't compile.  Same argument in Type.h

Oh; oops.  Didn't realize there was a dependency circle there.  I was
hoping we could use the cast templates to catch any mistakes with the
iterators.

-Eli
_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic