[LLVMdev] InstVisitor: RetType

Chris Lattner sabre at nondot.org
Wed May 31 12:54:00 PDT 2006


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/



More information about the llvm-dev mailing list