InstVisitor: RetType

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

InstVisitor: RetType

Bugzilla from ghost@cs.msu.su

Hi,
the docs for InstVisitor say that if RetType != void, one has to override
visitInstruction. What is the reason for that? It's valid to define
visitInstruction like that:

   RetTy visitInstruction(Instruction &I) { return RetTy(); }

so assuming RetTy has a sensible default constructor, user won't need to
override visitInstruction. Note that the above will work when RetTy ==
void, as checked by gcc and como, and confirmed by C++ standard.

Of course, RetTy() might not be a reasonable value for all cases, but that
can be left to user. Am I missing something?

- Volodya


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: InstVisitor: RetType

Chris Lattner
On Wed, 31 May 2006, Vladimir Prus wrote:

> the docs for InstVisitor say that if RetType != void, one has to override
> visitInstruction. What is the reason for that? It's valid to define
> visitInstruction like that:
>
>   RetTy visitInstruction(Instruction &I) { return RetTy(); }
>
> so assuming RetTy has a sensible default constructor, user won't need to
> override visitInstruction. Note that the above will work when RetTy ==
> void, as checked by gcc and como, and confirmed by C++ standard.
>
> Of course, RetTy() might not be a reasonable value for all cases, but that
> can be left to user. Am I missing something?

If that works, go for it.  Beware that it may break hp's acc or some other
compiler, but if noone complains about it, ok :)

-Chris

--
http://nondot.org/sabre/
http://llvm.org/
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev