native 0.0.1
Vectors, masks and wide register packs for C++26
Loading...
Searching...
No Matches
Typestate Analysis

Enabled in clang by passing -fsanitize=consumed. More...

Collaboration diagram for Typestate Analysis:

Macros

#define native_consumable(__x)
 Each class that uses any typestate annotations must first be marked using this attribute.
#define native_callable_when(...)
#define native_param_typestate(...)
#define native_return_typestate(...)
#define native_moving   native_return_typestate("consumed") native_param_typestate("unconsumed")
 [[return_typestate("consumed")]] [[param_typestate("unconsumed")]]
#define native_set_typestate(...)
#define native_test_typestate
#define native_test_typestate(...)

Detailed Description

Enabled in clang by passing -fsanitize=consumed.

Macro Definition Documentation

◆ native_callable_when

#define native_callable_when ( ...)

Use to indicate what states a method may be called in. Valid states are "unconsumed", "consumed", or "unknown". Each argument to this attribute must be a quoted string.

Definition at line 566 of file attributes.h.

◆ native_consumable

#define native_consumable ( __x)

Each class that uses any typestate annotations must first be marked using this attribute.

Failure to do so will result in a warning. This attribute accepts a single parameter that must be one of the following: "unknown", "consumed", or "unconsumed".

Definition at line 552 of file attributes.h.

◆ native_moving

#define native_moving   native_return_typestate("consumed") native_param_typestate("unconsumed")

[[return_typestate("consumed")]] [[param_typestate("unconsumed")]]

Short-hand for indicating that this argument was moved and is now "consumed". Assumes it was "unconsumed" before.

Definition at line 614 of file attributes.h.

◆ native_param_typestate

#define native_param_typestate ( ...)

This attribute specifies expectations about function parameters. Calls to a function with annotated parameters will issue a warning if the corresponding argument isn’t in the expected state. The attribute is also used to set the initial state of the parameter when analyzing the function’s body.

Definition at line 581 of file attributes.h.

◆ native_return_typestate

#define native_return_typestate ( ...)

The return_typestate attribute can be applied to functions or parameters.

When applied to a function the attribute specifies the state of the returned value. The function’s body is checked to ensure that it always returns a value in the specified state. On the caller side, values returned by the annotated function are initialized to the given state.

When applied to a function parameter it modifies the state of an argument after a call to the function returns. The function’s body is checked to ensure that the parameter is in the expected state before returning.

Definition at line 602 of file attributes.h.

◆ native_set_typestate

#define native_set_typestate ( ...)

Annotate methods that transition an object into a new state.

The new state must be "unconsumed", "consumed", or "unknown".

Definition at line 627 of file attributes.h.

◆ native_test_typestate [1/2]

#define native_test_typestate ( ...)

Use to indicate that a method returns true if the object is in the specified state.

The state must be "unconsumed", "consumed", or "unknown".

Definition at line 641 of file attributes.h.

◆ native_test_typestate [2/2]

#define native_test_typestate

Use to indicate that a method returns true if the object is in the specified state.

The state must be "unconsumed", "consumed", or "unknown".

Definition at line 641 of file attributes.h.