[PATCH] D25876: [analyzer] Report CFNumberGetValue API misuse
Artem Dergachev via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 25 11:54:57 PDT 2016
NoQ added inline comments.
================
Comment at: test/Analysis/CFNumber.c:39
+ unsigned char scalar = 0;
+ CFNumberGetValue(x, kCFNumberSInt16Type, &scalar); // expected-warning{{A CFNumber object that represents a 16-bit integer is used to initialize an 8-bit integer; 8 bits of the CFNumber value will overwrite adjacent storage}}
+ return scalar;
----------------
We're not sure from this code if the `CFNumber` object `x` actually represents a 16-bit integer, or somebody just misplaced the `kCFNumberSInt16Type` thing. I think the warning message could be made more precise in this sence, but i'm not good at coming up with warning messages.
Hmm, there could actually be a separate check for detecting inconsistent type specifiers used for accessing the same CFNumber object.
https://reviews.llvm.org/D25876
More information about the cfe-commits
mailing list