[PATCH] D25731: [analyzer] NumberObjectConversion: Support OSNumber and CFNumberRef.

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 20 11:28:21 PDT 2016


NoQ added a comment.

Ouch, i think i forgot about `OSNumber`, including tests.



================
Comment at: lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp:111
+  QualType ObjT = (IsCpp || IsObjC)
+                      ? Obj->getType().getCanonicalType().getUnqualifiedType()
+                      : Obj->getType();
----------------
zaks.anna wrote:
> Why do we need a case split here? Would calling getCanonicalType().getUnqualifiedType() result in a wrong result for ObjC?
It'd result in a wrong result for `CFNumberRef`, which is a typedef we shouldn't remove (turning this into `struct __CFNumber *` would be ugly).

I'd probably rather avoid the case split by removing the `.getCanonicalType()` part, because rarely anybody makes typedefs for `NSNumber*` or `OSBoolean*` etc (such as in tests with the word "sugared").

Or i could descend down to the necessary typedef for C objects, discarding all user's typedefs but not library typedefs. But that'd be even more complicated and probably not very useful for such minor matter.


https://reviews.llvm.org/D25731





More information about the cfe-commits mailing list