[LLVMdev] diffs for vc7.1
Misha Brukman
brukman at uiuc.edu
Fri Sep 3 13:07:47 PDT 2004
On Fri, Sep 03, 2004 at 03:01:01PM -0500, Anshu Dasgupta wrote:
> ><snip>
> >for (BasicBlock::iterator I = Dest->begin(); PHINode *PN =
> >dyn_cast<PHINode>(I); ++I)
> > visitPHINode(*PN);
> ><snip>
> >
> >build_vc71\lib\Transforms\Scalar\SCCP.cpp(202) : error C2275:
> >'llvm::PHINode' : illegal use of this type as an expression
> >
> >but I think is a NO-NO, so suggestions?
>
> Since it's fussy about a declaration in the for construct, perhaps
> something like this might work:
>
> PHINode *PN;
> for (BasicBlock::iterator I = Dest->begin(); (PN =
> dyn_cast<PHINode>(I)); ++I)
> ...
I think what you're arguing are really the same thing.
The for loop uses a dyn_cast<> which returns non-zero on success.
Paolo converted dyn_cast<> to isa<> which returns true precisely when
dyn_cast<> would return non-zero (which is what the for-loop actually
does). So I would say that Paolo's solution is just as valid, and
possibly cleaner, since isa<> returns a bool, while dyn_cast<> returns a
pointer.
--
Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu
More information about the llvm-dev
mailing list