[LLVMdev] -Woverloaded-virtual
Chris Lattner
sabre at nondot.org
Thu Jun 24 12:42:01 PDT 2004
On Thu, 24 Jun 2004, Vladimir Prus wrote:
> I've just had some fun, because I wanted to override
> FunctionPass::addAnalysisUsage, but forgot "const" after the method name --
> so instead of overriding I've just created a new unrelated method.
Ya know, I think that everyone has done that at least once (myself
included)... on THAT VERY METHOD. grr :)
I definitely think that it would be a good idea to add this -W flag :)
> After spending some time on this, I've decided to add
> -Woverloaded-virtual option to compiler to catch such cases. However, it
> also gives some warnings on LLVM code:
>
> ../../../include/llvm/Pass.h:264: warning: `virtual bool
> llvm::FunctionPass::run(llvm::Module&)' was hidden
> ../../../include/llvm/Pass.h:326: warning: by `bool
> llvm::BasicBlockPass::run(llvm::BasicBlock&)'
> ../../../include/llvm/Pass.h:275: warning: `virtual void
> llvm::FunctionPass::addToPassManager(llvm::PassManagerT<llvm::Module>*,
> llvm::AnalysisUsage&)' was hidden
> ../../../include/llvm/Pass.h:332: warning: by `virtual void
> llvm::BasicBlockPass::addToPassManager(llvm::PassManagerT<llvm::BasicBlock>*,
> llvm::AnalysisUsage&)'
>
> The problem is that "run" method is virtual in Path (with Module& as
> argument), but another version (non-virtual), which takes BasicBlock& is
> defined in BasicBlockPath.
Is that the only problem case?
> Do you think this warning is worth fixing? One possible approach is to
> rename virtual run(Module&) to runOnModule, but that would require
> updating all derived classes :-(
That is not a big deal necessarily. Is this the only case that currently
causes spurious warnings?
-Chris
--
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/
More information about the llvm-dev
mailing list