-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need -Woverloaded-virtual To Catch Inheritance Errors #759
Comments
The attached file was generated from my work on the bytecode analyzer which has |
Okay, well the first biggest step is to rectify the ones in the Pass class: virtual void print(std::ostream &O, const Module *M) const { print(O); } There is no reason for the second one. We should just change any who implement -Chris |
Mine |
Schedule for 1.5 |
This patch fixes 1/2 of the warnings, those coming from utils/TableGen/Record.h: http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20041206/021811.html |
At this point, the only remaining problem is: /proj/work/llvm/build/../llvm/include/llvm/Pass.h:292: warning: However, my attempts to fix this one have not succeeded. Doing the obvious thing Perhaps someone who's cozy and intimate with the PassManager can take a look at |
A recitation of the problem: The -Woverloaded-virtual flag is in GCC for a really good reason; becase the class X { pubic: virtual void nada(int); }; then there is no way to call nada(int) from a Y*. The language requires Using our example above, there are two ways to solve this problem: Unfortunately, the patches so far have chosen (b) as the solution so that the Consequently, we're going to switch to option (a) for solution. Its more |
Note that there's yet another method: add using X::nada; in the declaration of class Y. This is actually pretty clean approach. However, it does not work when X::nada is private, as is the case with those |
With the recent modifications to the PassManager and a few other places, this |
Extended Description
We need to start using the -Woverloaded-virtual option in the makefiles to catch
some inheritance bugs. Patches for this bug should first rid all of LLVM of
warnings produced by -Woverloaded-virtual option and then patch the makefiles to
turn the option on.
This idea submitted by Vladimir Prus where he made the following comments on
LLVMdev list:
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.
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
boolllvm::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 voidllvm::BasicBlockPass::addToPassManager(llvm::PassManagerTllvm::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.
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 :-(
The text was updated successfully, but these errors were encountered: