From 8213813c6d0924fb0e42acc0ff8effe75acf9175 Mon Sep 17 00:00:00 2001 From: theraven Date: Thu, 10 Feb 2011 12:15:09 +0000 Subject: [PATCH] Added some macros for use with the static analyser. Turned _reserved ivar in GSSpellServer into GS_PADDING_IVAR (no change to class layout). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32036 72102866-910b-0410-8b05-ffd578937521 --- .../Additions/GNUstepBase/GSVersionMacros.h | 45 +++++++++++++++++++ Headers/Foundation/NSException.h | 4 +- Headers/Foundation/NSSpellServer.h | 2 +- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/Headers/Additions/GNUstepBase/GSVersionMacros.h b/Headers/Additions/GNUstepBase/GSVersionMacros.h index 8fce6674b..4901ca167 100644 --- a/Headers/Additions/GNUstepBase/GSVersionMacros.h +++ b/Headers/Additions/GNUstepBase/GSVersionMacros.h @@ -238,6 +238,51 @@ # endif #endif +/* Static analyser macros: Provide annotations to help the analyser */ +// TODO: Make this more sensible when GCC supports __attribute__((unused)) on +// ivars +#ifdef __clang__ +# define GS_UNUSED_IVAR __attribute__((unused)) +# define GS_NORETURN_METHOD __attribute__((__noreturn__)) +#else +# define GS_UNUSED_IVAR +# define GS_NORETURN_METHOD +#endif + +#ifndef NS_RETURNS_RETAINED +# if __has_feature(attribute_ns_returns_retained) +# define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) +# else +# define NS_RETURNS_RETAINED +# endif +#endif + +#ifndef NS_RETURNS_NOT_RETAINED +# if __has_feature(attribute_ns_returns_not_retained) +# define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained)) +# else +# define NS_RETURNS_NOT_RETAINED +# endif +#endif + +#ifndef NS_CONSUMED +# if __has_feature(attribute_ns_consumed) +# define NS_CONSUMED __attribute__((ns_consumed)) +# else +# define NS_CONSUMED +# endif +#endif + + +#ifndef NS_CONSUMES_SELF +# if __has_feature(attribute_ns_consumes_self) +# define NS_CONSUMES_SELF __attribute__((ns_consumes_self)) +# else +# define NS_CONSUMES_SELF +# 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 diff --git a/Headers/Foundation/NSException.h b/Headers/Foundation/NSException.h index 9fcd35046..7d0cc8654 100644 --- a/Headers/Foundation/NSException.h +++ b/Headers/Foundation/NSException.h @@ -380,13 +380,13 @@ GS_EXPORT void _NSRemoveHandler( NSHandler *handler ); - (void) handleFailureInFunction: (NSString*)functionName file: (NSString*)fileName lineNumber: (NSInteger)line - description: (NSString*)format,...; + description: (NSString*)format,... GS_NORETURN_METHOD; - (void) handleFailureInMethod: (SEL)aSelector object: object file: (NSString*)fileName lineNumber: (NSInteger)line - description: (NSString*)format,...; + description: (NSString*)format,... GS_NORETURN_METHOD; @end extern NSString *const NSAssertionHandlerKey; diff --git a/Headers/Foundation/NSSpellServer.h b/Headers/Foundation/NSSpellServer.h index 99db1f31d..6f843d988 100644 --- a/Headers/Foundation/NSSpellServer.h +++ b/Headers/Foundation/NSSpellServer.h @@ -63,8 +63,8 @@ GS_EXPORT NSString *const NSGrammarUserDescription; NSMutableDictionary *_userDictionaries; NSString *_currentLanguage; NSArray *_ignoredWords; - void *_reserved; #endif + GS_PADDING_IVAR; } // Checking in Your Service