Add a GS_PADDING_IVAR macro. This defines the void *gs_unused; instance variable with __attribute__((unused)) on clang so that the static analyser only reports unused ivars that we expect to be used. This also makes it slightly easier to add the padding ivar to new classes.

Note: The padding ivar has been added to NSRegularExpression.  This will break the ABI for anyone subclassing NSRegularExpression, but hopefully that's no one (done before the next release, to make sure that we don't break the ABI between releases, only for people following -trunk).



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32033 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
David Chisnall 2011-02-10 11:02:50 +00:00
parent 5d623d76fc
commit c7c3c7c02e
35 changed files with 47 additions and 108 deletions

View file

@ -75,9 +75,7 @@ extern "C" {
NSMutableDictionary *objects;
NSMutableDictionary *params;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
+ (NSString*) makeQuoted: (NSString*)v always: (BOOL)flag;
+ (NSString*) makeToken: (NSString*)t preservingCase: (BOOL)preserve;

View file

@ -228,6 +228,16 @@
#define GS_EXPOSE(X) (!GS_NONFRAGILE || defined(EXPOSE_##X##_IVARS))
#ifdef GS_NONFRAGILE
# define GS_PADDING_IVAR
#else
# ifdef __clang__
# define GS_PADDING_IVAR __attribute__((unused)) void *gs_unused;
# else
# define GS_PADDING_IVAR void *gs_unused;
# endif
#endif
/* Include the appropriate header for ObjC2 blocks support if it is in use.
*
* FIXME: "OBJC2RUNTIME" is set to "1" if the runtime has

View file

@ -70,9 +70,7 @@ extern "C" {
BOOL _encodingRoot;
BOOL _initialPass;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/* Initializing an archiver */
@ -178,9 +176,7 @@ extern "C" {
NSMutableDictionary *objDict; /* Class information store. */
NSMutableArray *objSave;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/* Initializing an unarchiver */

View file

@ -194,9 +194,7 @@ typedef struct autorelease_array_list
/* The method to add an object to this pool */
void (*_addImp)(id, SEL, id);
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/**

View file

@ -119,9 +119,7 @@ GS_EXPORT NSString* const NSLoadedClasses;
unsigned _version;
NSString *_frameworkVersion;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/** Return an array enumerating all the bundles in the application. This

View file

@ -61,9 +61,7 @@ extern "C" {
/** Total number of accesses to objects */
int64_t _totalAccesses;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/**
* Returns the maximum number of objects that are supported by this cache.

View file

@ -77,9 +77,7 @@ typedef enum _NSPredicateOperatorType
NSUInteger _options;
NSPredicateOperatorType _type;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
@public
NSExpression *_left;
NSExpression *_right;

View file

@ -134,9 +134,7 @@ typedef NSUInteger NSDateFormatterBehavior;
NSDateFormatterStyle _dateStyle;
void *_formatter;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/* Initializing an NSDateFormatter */

View file

@ -129,9 +129,7 @@ extern "C" {
BOOL _raiseOnUnderflow;
BOOL _raiseOnDivideByZero;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/**

View file

@ -40,9 +40,7 @@ extern "C" {
NSString *_lockPath;
NSDate *_lockTime;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
+ (NSDistributedLock*) lockWithPath: (NSString*)aPath;

View file

@ -86,9 +86,7 @@ GS_EXPORT NSString* const GSNetworkNotificationCenterType;
id _remote; /* Proxy for center. */
BOOL _suspended; /* Is delivery suspended? */
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
+ (NSNotificationCenter*) defaultCenter;
+ (NSNotificationCenter*) notificationCenterForType: (NSString*)type;

View file

@ -121,9 +121,7 @@ GS_EXPORT NSString* const NSCocoaErrorDomain;
NSString *_domain;
NSDictionary *_userInfo;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/**

View file

@ -162,9 +162,7 @@ GS_EXPORT NSString * const NSFileHandleOperationException;
NSFileHandle *_readHandle;
NSFileHandle *_writeHandle;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
+ (id) pipe;
- (NSFileHandle*) fileHandleForReading;

View file

@ -203,9 +203,7 @@ typedef uint32_t OSType;
@private
NSString *_lastError;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
+ (NSFileManager*) defaultManager;
@ -389,9 +387,7 @@ typedef uint32_t OSType;
BOOL justContents: 1;
} _flags;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
- (NSDictionary*) directoryAttributes;
- (NSDictionary*) fileAttributes;

View file

@ -44,9 +44,7 @@ extern "C" {
NSSet *_names;
NSSet *_addresses;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/**

View file

@ -50,9 +50,7 @@ extern "C" {
NSUInteger _length;
NSUInteger *_indexes;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/**

View file

@ -50,9 +50,7 @@ extern "C" {
BOOL _sendToSuper;
void *_retptr;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/*

View file

@ -71,9 +71,7 @@ extern "C" {
NSMutableArray *_obj; /* Array of objects. */
NSPropertyListFormat _format;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/**
@ -240,9 +238,7 @@ extern "C" {
#endif
NSZone *_zone; /* Zone for allocating objs. */
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/**

View file

@ -104,9 +104,7 @@ GS_EXPORT NSString * const NSISO8601Calendar;
NSString *_localeId;
NSMutableDictionary *_components;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)

View file

@ -145,9 +145,7 @@ typedef NSUInteger NSNumberFormatterRoundingMode;
NSLocale *_locale;
void *_formatter;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
// Format

View file

@ -211,9 +211,7 @@ typedef SOCKET NSSocketNativeHandle;
NSMapTable *events;
#endif
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/**

View file

@ -94,9 +94,7 @@ extern "C" {
unsigned _version; /* Version of archiver used. */
NSZone *_zone; /* Zone for allocating objs. */
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/**

View file

@ -51,9 +51,7 @@ extern "C" {
NSPort *_send;
NSMutableArray *_components;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/**
* OpenStep compatibility.

View file

@ -60,9 +60,7 @@ extern "C" {
NSMapTable *_portMap; /* Registered ports information. */
NSMapTable *_nameMap; /* Registered names information. */
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
+ (id) sharedInstance;
- (NSPort*) portForName: (NSString*)name

View file

@ -42,9 +42,7 @@ extern "C" {
Protocol *_myProtocol;
NSObject *_myTarget;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
// Creating a checker

View file

@ -37,6 +37,7 @@ DEFINE_BLOCK_TYPE(GSRegexBlock, void, NSTextCheckingResult*, NSMatchingFlags, BO
@private
GSREGEXTYPE *regex;
NSRegularExpressionOptions options;
GS_PADDING_IVAR;
}
+ (NSRegularExpression*)regularExpressionWithPattern: (NSString*)aPattern
options: (NSRegularExpressionOptions)opts

View file

@ -50,9 +50,7 @@ extern "C" {
BOOL _caseSensitive;
BOOL _isUnicode;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/*

View file

@ -50,9 +50,7 @@ extern "C" {
BOOL _ascending;
SEL _selector;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/** Returns a flag indicating whether the sort descriptor sorts objects

View file

@ -54,9 +54,7 @@ extern "C" {
BOOL _hasCollected;
BOOL _hasNotified;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
+ (NSTask*) launchedTaskWithLaunchPath: (NSString*)path

View file

@ -72,9 +72,7 @@ extern "C" {
id _gcontext;
void *_runLoopInfo; // Per-thread runloop related info.
#endif
#if !GS_NONFRAGILE
void *_unused; // For future expansion
#endif
GS_PADDING_IVAR;
}
/**

View file

@ -51,9 +51,7 @@ extern "C" {
SEL _selector;
id _info;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/* Creating timer objects. */

View file

@ -98,9 +98,7 @@ GS_EXPORT NSString* const NSUndoManagerWillUndoChangeNotification;
unsigned _disableCount;
unsigned _levelsOfUndo;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
- (void) beginUndoGrouping;

View file

@ -228,9 +228,7 @@ GS_EXPORT NSString* const GSLocale;
NSRecursiveLock *_lock;
NSDistributedLock *_fileLock;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/**

View file

@ -88,9 +88,7 @@ typedef NSUInteger NSXMLNodeKind;
NSUInteger _index;
id _objectValue;
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/**

View file

@ -74,9 +74,7 @@ GS_EXPORT NSString* const NSXMLParserErrorDomain;
void *_parser; // GSXMLParser
void *_handler; // SAXHandler
#endif
#if !GS_NONFRAGILE
void *_unused;
#endif
GS_PADDING_IVAR;
}
/**