Expected results: that should work. I've poisoned "initWithCString:" but used "initWithCString:encoding:".
Actual results: two errors are emitted.
Untitled.m:2:35: error: can only poison identifier tokens
pragma GCC poison initWithCString:
^
Untitled.m:6:37: error: attempt to use a poisoned identifier
NSString *foo = [[NSString alloc] initWithCString:"foo" encoding:NSUTF8StringEncoding];
^
2 errors generated.
Notes: whether it's a separate pragma or not, I would like to enforce Objective-C code guidelines by poisoning specific selectors. That shouldn't poison other selectors that happen to contain my poisoned selectors in substrings.
+1. There are so many methods Apple doesn't actually mark deprecated in their SDK (or does so only by comment), it would be great to build our own lists.
Extended Description
Summary: Clang inherits the "poison" pragma from GCC. Unfortunately it doesn't support poisoning Objective-C selectors very well.
Steps to reproduce: compile this code.
import <Foundation/Foundation.h>
pragma GCC poison initWithCString:
int main(int argc, char argv[]) { @autoreleasepool { NSString foo = [[NSString alloc] initWithCString:"foo" encoding:NSUTF8StringEncoding]; NSLog(@"%@", foo); } }
Expected results: that should work. I've poisoned "initWithCString:" but used "initWithCString:encoding:".
Actual results: two errors are emitted.
Untitled.m:2:35: error: can only poison identifier tokens
pragma GCC poison initWithCString:
Untitled.m:6:37: error: attempt to use a poisoned identifier NSString *foo = [[NSString alloc] initWithCString:"foo" encoding:NSUTF8StringEncoding]; ^ 2 errors generated.
Notes: whether it's a separate pragma or not, I would like to enforce Objective-C code guidelines by poisoning specific selectors. That shouldn't poison other selectors that happen to contain my poisoned selectors in substrings.