[cfe-dev] Extending printf format string checking to cover ObjC format strings in NSLog
nikita at zhuk.fi
Mon Jun 16 13:13:58 PDT 2008
On 16.6.2008, at 21.38, Ted Kremenek wrote:
> This functionality should eventually go in as well. The set of such
> CF functions should be small. Other functions that use Objective-C
> style format strings should generally be labeled with the
> __NSString__ attribute. Unfortunately, it looks like the
> "initWithFormat:" methods do not have this attribute:
> Fortunately, it looks like the set of methods to hardwire support
> for is small.
I wasn't aware of format(__NSString__) attribute, but it would clearly
be beneficial to recognize format NSStrings based on it.
Actually the NSLog() function seems to be the only function or method
in AppKit & Foundation headers which uses this attribute. I've found
several functions and methods which use format NSStrings and don't use
the format(__NSString__) attribute: 12 functions in AppKit/NSPanel.h,
4 functions in CoreFoundation/CFString.h, 4 methods in Foundation/
NSException.h and 8 methods in Foundation/NSString.h.
So hardcoding both function and method names seems inevitable.
More information about the cfe-dev