Changeset View
Changeset View
Standalone View
Standalone View
clang/include/clang/Basic/AttrDocs.td
Show First 20 Lines • Show All 4,228 Lines • ▼ Show 20 Lines | |||||
not initialized on device side. It has internal linkage and is initialized by | not initialized on device side. It has internal linkage and is initialized by | ||||
the initializer on host side. | the initializer on host side. | ||||
}]; | }]; | ||||
} | } | ||||
def LifetimeOwnerDocs : Documentation { | def LifetimeOwnerDocs : Documentation { | ||||
let Category = DocCatDecl; | let Category = DocCatDecl; | ||||
let Content = [{ | let Content = [{ | ||||
.. Note:: This attribute is experimental and its effect on analysis is subject to change in | .. Note:: This attribute is experimental and its effect on analysis is subject to change in | ||||
a future version of clang. | a future version of clang. | ||||
The attribute ``[[gsl::Owner(T)]]`` applies to structs and classes that own an | The attribute ``[[gsl::Owner(T)]]`` applies to structs and classes that own an | ||||
object of type ``T``: | object of type ``T``: | ||||
rsmith: ... and what does the attribute mean when the argument is omitted? | |||||
I added text that it is currently ignored. We will use the argument in future analysis, but already add parsing of it for forward compatibility. mgehre: I added text that it is currently ignored. We will use the argument in future analysis, but… | |||||
.. code-block:: c++ | .. code-block:: c++ | ||||
class [[gsl::Owner(int)]] IntOwner { | class [[gsl::Owner(int)]] IntOwner { | ||||
private: | private: | ||||
int value; | int value; | ||||
public: | public: | ||||
int *getInt() { return &value; } | int *getInt() { return &value; } | ||||
}; | }; | ||||
The argument ``T`` is optional and currently ignored. | The argument ``T`` is optional and is ignored. | ||||
This attribute may be used by analysis tools and has no effect on code | This attribute may be used by analysis tools and has no effect on code | ||||
generation. | generation. | ||||
See Pointer_ for an example. | See Pointer_ for an example. | ||||
}]; | }]; | ||||
} | } | ||||
def LifetimePointerDocs : Documentation { | def LifetimePointerDocs : Documentation { | ||||
let Category = DocCatDecl; | let Category = DocCatDecl; | ||||
let Content = [{ | let Content = [{ | ||||
.. Note:: This attribute is experimental and its effect on analysis is subject to change in | .. Note:: This attribute is experimental and its effect on analysis is subject to change in | ||||
Similarly, what happens in that case? rsmith: Similarly, what happens in that case? | |||||
a future version of clang. | a future version of clang. | ||||
The attribute ``[[gsl::Pointer(T)]]`` applies to structs and classes that behave | The attribute ``[[gsl::Pointer(T)]]`` applies to structs and classes that behave | ||||
like pointers to an object of type ``T``: | like pointers to an object of type ``T``: | ||||
.. code-block:: c++ | .. code-block:: c++ | ||||
class [[gsl::Pointer(int)]] IntPointer { | class [[gsl::Pointer(int)]] IntPointer { | ||||
private: | private: | ||||
int *valuePointer; | int *valuePointer; | ||||
public: | public: | ||||
int *getInt() { return &valuePointer; } | int *getInt() { return &valuePointer; } | ||||
}; | }; | ||||
The argument ``T`` is optional and currently ignored. | The argument ``T`` is optional and is ignored. | ||||
This attribute may be used by analysis tools and has no effect on code | This attribute may be used by analysis tools and has no effect on code | ||||
generation. | generation. | ||||
Example: | Example: | ||||
When constructing an instance of a class annotated like this (a Pointer) from | When constructing an instance of a class annotated like this (a Pointer) from | ||||
an instance of a class annotated with ``[[gsl::Owner]]`` (an Owner), | an instance of a class annotated with ``[[gsl::Owner]]`` (an Owner), | ||||
then the analysis will consider the Pointer to point inside the Owner. | then the analysis will consider the Pointer to point inside the Owner. | ||||
When the Owner's lifetime ends, it will consider the Pointer to be dangling. | When the Owner's lifetime ends, it will consider the Pointer to be dangling. | ||||
Show All 14 Lines |
... and what does the attribute mean when the argument is omitted?