[cfe-dev] Working on my first patch for the static analyzer, few questions.
Emily Bellows
emily.a.bellows at gmail.com
Wed Dec 3 17:30:33 PST 2014
Hi everyone,
I’ve been writing one of the potential checkers from the clang-analyzer website. It detects calls to member functions before all base classes are initialized in a constructor initializer list, which the standard says is undefined behavior (C++11 12.6.2.p13.)
My checker finds these cases fine, it runs perfectly on the examples given from the standard, and I ran it on the LLVM codebase and it even found three instances of this (calls to allocHungoffUses in lib/IR/Instructions.cpp if you’re curious, lines 89, 196, and 3579.)
Questions,
1. Does this seem like it might be better as a compiler warning? Right now the checker only uses checkASTDecl, and so is not path sensitive. It could be made path sensitive in the future to detect code indirectly using ’this’, however.
2. Does the ReportBug method look sensible? Given the check is not path sensitive, I couldn’t quite figure out what the PathDiagnosticLocation class is supposed to represent, or whether or not I’m using it correctly because most of the constructors take an ExplodedNode. The error messages my checker gives out looks reasonable to me, so it works, but I’m not sure if it’s idiomatic usage of the reporting API.
Example error:
/Users/emilybellows/Workspace/llvm/lib/IR/Instructions.cpp:89:17: warning:
Method called before all bases were initialized
allocHungoffUses(PN.getNumOperands()), PN.getNumOperands()),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3. Who is the code owner of this part of clang for when I end up submitting the patch. Is the owner Chris Lattner by default? And does this patch look ready to submit to cfe-commits?
I welcome any other comments too, this is my first time working with either LLVM or Clang, and my first time contributing code to an open source project.
Thanks,
Emily
-------------- next part --------------
A non-text attachment was scrubbed...
Name: newchecker.patch
Type: application/octet-stream
Size: 5608 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141203/56b0db77/attachment.obj>
-------------- next part --------------
More information about the cfe-dev
mailing list