improving detection of uninitialized arguments (the CallAndMessageChecker)
Per Viberg
Per.Viberg at evidente.se
Wed Feb 26 05:29:22 PST 2014
Hi,
I've extended the check that warns for uninitialized arguments to:
- warn for pointer arguments that point to uninitialized local (stack) variables.
- warn for function calls with uninitialized arguments, when the corresponding function parameter is a const reference.
void doStuff(const int *p);
void doStuffRef(const int& c);
void f(void) {
int x;
doStuff(&x); // warning
}
void g(void) {
int x;
doStuffRef(x); // warning
I've also parameterize the CallAndMessageChecker in a similar way as CheckSecuritySyntaxOnly.
that is:
// only check if arguments are uninitialized (the old functionality only)
clang -cc1 -analyze -analyzer-checker=core.callandmessage uninit-const.cpp
// with extended functionality, i.e. "check if const pointer arguments are uninitialized" (also performs the old check).
clang -cc1 -analyze -analyzer-checker=alpha.core.CallAndMessageUnInitRefArgChecker uninit-const.cpp
/Per
.......................................................................................................................
Per Viberg Senior Engineer
Evidente ES East AB Warfvinges väg 34 SE-112 51 Stockholm Sweden
Phone: +46 (0)8 402 79 00
Mobile: +46 (0)70 912 42 52
E-mail: Per.Viberg at evidente.se<mailto:Per.Viberg at evidente.se>
www.evidente.se<http://www.evidente.se>
This e-mail, which might contain confidential information, is addressed to the above stated person/company. If you are not the correct addressee, employee or in any other way the person concerned, please notify the sender immediately. At the same time, please delete this e-mail and destroy any prints. Thank You.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140226/abecae06/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: refToUninitConst_rev1.diff
Type: text/x-patch
Size: 11160 bytes
Desc: refToUninitConst_rev1.diff
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140226/abecae06/attachment.bin>
More information about the cfe-commits
mailing list