Cthulhu  0.2.10
Cthulhu compiler collection
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Static analysis decorators

Decorators for static analysis tools. More...

Collaboration diagram for Static analysis decorators:

Macros

#define RET_DOMAIN(cmp, it)
 annotate the return value as being bounded by the expression of cmp and it RET_DOMAIN(!=, 0) means the returned value will never be 0 More...
 
#define RET_NOTNULL
 annotate the return value as not being null More...
 
#define RET_NOTNULL   0
 annotate the return value as not being null More...
 
#define RET_INSPECT
 annotate the return value as needing to be inspected this is the same as CT_NODISCARD but implies that the return value must be checked for errors More...
 
#define IN_NOTNULL
 annotate a parameter as not being null More...
 
#define IN_NOTNULL   0
 annotate a parameter as not being null More...
 
#define IN_STRING
 annotate a parameter as being a null terminated string More...
 
#define IN_DOMAIN(cmp, it)
 annotate a parameter as being bounded by the expression of cmp and it More...
 
#define OUT_NOTNULL
 
#define INOUT_NOTNULL
 
#define STA_DECL
 sal2 annotation on function implementations to copy annotations from the declaration More...
 
#define STA_RET_NEVER
 
#define STA_RET_RANGE(lo, hi)
 
#define STA_RET_NOTNULL
 
#define STA_RET_STRING
 annotate the return value as a null terminated string More...
 
#define STA_SUCCESS(expr)
 
#define STA_SUCCESS_TYPE(expr)
 
#define STA_LAST_ERROR
 
#define STA_FIELD_SIZE(of)
 annotate a field as being an array of of elements More...
 
#define STA_FIELD_STRING
 annotate a field as being a null terminated string More...
 
#define STA_FIELD_RANGE(lo, hi)
 annotate a field as being bounded by the expression of cmp and it STA_FIELD_RANGE(!=, 0) means the field will never be 0 More...
 
#define STA_UPDATES(size)
 
#define STA_READS(size)
 annotate a parameter as reading expr elements More...
 
#define STA_WRITES(size)
 annotate a parameter as writing expr elements More...
 
#define STA_UPDATES_CSTRING(size)
 
#define STA_READS_CSTRING(size)
 
#define STA_WRITES_CSTRING(size)
 
#define STA_FORMAT_STRING
 mark a function parameter as a printf format string More...
 
#define STA_OUT_OPT
 
#define STA_OUT_CSTRING
 
#define STA_OUT_RANGE(lo, hi)
 
#define STA_OUT_INVALID
 
#define STA_IN_RANGE(lo, hi)
 
#define STA_INOUT
 
#define STA_INOUT_OPT
 
#define STA_INOUT_CSTRING
 
#define CT_NORETURN   STA_RET_NEVER CT_NORETURN_IMPL
 
#define STA_RELEASE   IN_NOTNULL STA_OUT_INVALID
 annotate a pointer as invalid after the function returns More...
 
#define STA_PRINTF(a, b)
 mark a function as a printf style function More...
 
#define CT_ATTRIB(...)
 any attribute that both gcc and clang support More...
 
#define CT_GNU_ATTRIB(...)
 gcc only attributes More...
 
#define CT_CLANG_ATTRIB(...)
 clang only attributes More...
 
#define CT_DECLSPEC(...)
 
#define CT_NODISCARD   CT_ATTRIB(warn_unused_result)
 mark a function as returning a value that must be used More...
 
#define CT_NODISCARD   0
 mark a function as returning a value that must be used More...
 
#define CT_NOALIAS   CT_DECLSPEC(noalias)
 mark a function as only modifying pointers passed to it the same as CT_CONSTFN but allowed to modify/inspect pointers passed to it More...
 
#define CT_CONSTFN   CT_ATTRIB(const)
 mark a function as const, has no side effects and always returns the same value for the same arguments More...
 
#define CT_PUREFN   CT_ATTRIB(pure)
 mark a function as pure, always returns the same value for the same arguments More...
 
#define CT_ALLOC(...)
 mark a function as allocating memory More...
 
#define CT_ALLOC_SIZE(...)   CT_ATTRIB(alloc_size(__VA_ARGS__))
 mark a function as allocating memory with a specific size More...
 
#define CT_RESTRICT   restrict
 
#define CT_HOTFN   CT_ATTRIB(hot)
 mark a function as hot, it is likely to be called often More...
 
#define CT_COLDFN   CT_ATTRIB(cold)
 mark a function as cold, it is unlikely to be called often More...
 

Detailed Description

Decorators for static analysis tools.

Macro Definition Documentation

◆ CT_ALLOC

#define CT_ALLOC (   ...)

mark a function as allocating memory

Definition at line 244 of file analyze.h.

◆ CT_ALLOC_SIZE

#define CT_ALLOC_SIZE (   ...)    CT_ATTRIB(alloc_size(__VA_ARGS__))

mark a function as allocating memory with a specific size

Definition at line 247 of file analyze.h.

◆ CT_ATTRIB

#define CT_ATTRIB (   ...)

any attribute that both gcc and clang support

◆ CT_CLANG_ATTRIB

#define CT_CLANG_ATTRIB (   ...)

clang only attributes

◆ CT_COLDFN

#define CT_COLDFN   CT_ATTRIB(cold)

mark a function as cold, it is unlikely to be called often

Definition at line 269 of file analyze.h.

◆ CT_CONSTFN

#define CT_CONSTFN   CT_ATTRIB(const)

mark a function as const, has no side effects and always returns the same value for the same arguments

Warning
do not apply this to functions that take pointers as arguments

Definition at line 227 of file analyze.h.

◆ CT_DECLSPEC

#define CT_DECLSPEC (   ...)

Definition at line 185 of file analyze.h.

◆ CT_GNU_ATTRIB

#define CT_GNU_ATTRIB (   ...)

gcc only attributes

◆ CT_HOTFN

#define CT_HOTFN   CT_ATTRIB(hot)

mark a function as hot, it is likely to be called often

Definition at line 268 of file analyze.h.

◆ CT_NOALIAS

#define CT_NOALIAS   CT_DECLSPEC(noalias)

mark a function as only modifying pointers passed to it the same as CT_CONSTFN but allowed to modify/inspect pointers passed to it

Definition at line 226 of file analyze.h.

◆ CT_NODISCARD [1/2]

#define CT_NODISCARD   CT_ATTRIB(warn_unused_result)

mark a function as returning a value that must be used

◆ CT_NODISCARD [2/2]

#define CT_NODISCARD   0

mark a function as returning a value that must be used

◆ CT_NORETURN

#define CT_NORETURN   STA_RET_NEVER CT_NORETURN_IMPL

Definition at line 150 of file analyze.h.

◆ CT_PUREFN

#define CT_PUREFN   CT_ATTRIB(pure)

mark a function as pure, always returns the same value for the same arguments

Warning
must not depend on mutable global state or have side effects
Note
thats a lie actually, gcc says it may have calls to it optimized away via CSE

Definition at line 228 of file analyze.h.

◆ CT_RESTRICT

#define CT_RESTRICT   restrict

Definition at line 260 of file analyze.h.

◆ IN_DOMAIN

#define IN_DOMAIN (   cmp,
  it 
)

annotate a parameter as being bounded by the expression of cmp and it

◆ IN_NOTNULL [1/2]

#define IN_NOTNULL

annotate a parameter as not being null

◆ IN_NOTNULL [2/2]

#define IN_NOTNULL   0

annotate a parameter as not being null

◆ IN_STRING

#define IN_STRING

annotate a parameter as being a null terminated string

◆ INOUT_NOTNULL

#define INOUT_NOTNULL

Definition at line 101 of file analyze.h.

◆ OUT_NOTNULL

#define OUT_NOTNULL

Definition at line 99 of file analyze.h.

◆ RET_DOMAIN

#define RET_DOMAIN (   cmp,
  it 
)

annotate the return value as being bounded by the expression of cmp and it RET_DOMAIN(!=, 0) means the returned value will never be 0

static analysis macros old macros not prefixed with STA_ are deprecated

Parameters
cmpthe comparison operator
itthe expression to compare against

◆ RET_INSPECT

#define RET_INSPECT

annotate the return value as needing to be inspected this is the same as CT_NODISCARD but implies that the return value must be checked for errors

◆ RET_NOTNULL [1/2]

#define RET_NOTNULL

annotate the return value as not being null

◆ RET_NOTNULL [2/2]

#define RET_NOTNULL   0

annotate the return value as not being null

◆ STA_DECL

#define STA_DECL

sal2 annotation on function implementations to copy annotations from the declaration

◆ STA_FIELD_RANGE

#define STA_FIELD_RANGE (   lo,
  hi 
)

annotate a field as being bounded by the expression of cmp and it STA_FIELD_RANGE(!=, 0) means the field will never be 0

Parameters
cmpthe comparison operator
itthe expression to compare against

◆ STA_FIELD_SIZE

#define STA_FIELD_SIZE (   of)

annotate a field as being an array of of elements

Parameters
ofthe number of elements in the array

◆ STA_FIELD_STRING

#define STA_FIELD_STRING

annotate a field as being a null terminated string

◆ STA_FORMAT_STRING

#define STA_FORMAT_STRING

mark a function parameter as a printf format string

◆ STA_IN_RANGE

#define STA_IN_RANGE (   lo,
  hi 
)

Definition at line 142 of file analyze.h.

◆ STA_INOUT

#define STA_INOUT

Definition at line 145 of file analyze.h.

◆ STA_INOUT_CSTRING

#define STA_INOUT_CSTRING

Definition at line 147 of file analyze.h.

◆ STA_INOUT_OPT

#define STA_INOUT_OPT

Definition at line 146 of file analyze.h.

◆ STA_LAST_ERROR

#define STA_LAST_ERROR

Definition at line 115 of file analyze.h.

◆ STA_OUT_CSTRING

#define STA_OUT_CSTRING

Definition at line 137 of file analyze.h.

◆ STA_OUT_INVALID

#define STA_OUT_INVALID

Definition at line 139 of file analyze.h.

◆ STA_OUT_OPT

#define STA_OUT_OPT

Definition at line 136 of file analyze.h.

◆ STA_OUT_RANGE

#define STA_OUT_RANGE (   lo,
  hi 
)

Definition at line 138 of file analyze.h.

◆ STA_PRINTF

#define STA_PRINTF (   a,
 
)

mark a function as a printf style function

Parameters
athe index of the format string parameter
bthe index of the first variadic parameter

Definition at line 165 of file analyze.h.

◆ STA_READS

#define STA_READS (   size)

annotate a parameter as reading expr elements

Parameters
exprthe number of elements read

◆ STA_READS_CSTRING

#define STA_READS_CSTRING (   size)

Definition at line 129 of file analyze.h.

◆ STA_RELEASE

#define STA_RELEASE   IN_NOTNULL STA_OUT_INVALID

annotate a pointer as invalid after the function returns

◆ STA_RET_NEVER

#define STA_RET_NEVER

Definition at line 107 of file analyze.h.

◆ STA_RET_NOTNULL

#define STA_RET_NOTNULL

Definition at line 109 of file analyze.h.

◆ STA_RET_RANGE

#define STA_RET_RANGE (   lo,
  hi 
)

Definition at line 108 of file analyze.h.

◆ STA_RET_STRING

#define STA_RET_STRING

annotate the return value as a null terminated string

◆ STA_SUCCESS

#define STA_SUCCESS (   expr)

Definition at line 113 of file analyze.h.

◆ STA_SUCCESS_TYPE

#define STA_SUCCESS_TYPE (   expr)

Definition at line 114 of file analyze.h.

◆ STA_UPDATES

#define STA_UPDATES (   size)

Definition at line 123 of file analyze.h.

◆ STA_UPDATES_CSTRING

#define STA_UPDATES_CSTRING (   size)

Definition at line 128 of file analyze.h.

◆ STA_WRITES

#define STA_WRITES (   size)

annotate a parameter as writing expr elements

Parameters
exprthe number of elements written

◆ STA_WRITES_CSTRING

#define STA_WRITES_CSTRING (   size)

Definition at line 130 of file analyze.h.