Skip to content

Commit

Permalink
[clang][docs] Update the gsl::Pointer/Owner attr doc (#96908)
Browse files Browse the repository at this point in the history
- Fix some errors in the snippet;
- update the code snippet to reflect the current implementation status
in clang;
  • Loading branch information
hokein authored Jun 27, 2024
1 parent aa3589f commit e258bb3
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions clang/include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -6585,7 +6585,8 @@ like pointers to an object of type ``T``:
private:
int *valuePointer;
public:
int *getInt() { return &valuePointer; }
IntPointer(const IntOwner&);
int *getInt() { return valuePointer; }
};

The argument ``T`` is optional and is ignored.
Expand All @@ -6601,12 +6602,8 @@ When the Owner's lifetime ends, it will consider the Pointer to be dangling.
.. code-block:: c++

int f() {
IntPointer P;
if (true) {
IntOwner O(7);
P = IntPointer(O); // P "points into" O
} // P is dangling
return P.get(); // error: Using a dangling Pointer.
IntPointer P(IntOwner{}); // P "points into" a temporary IntOwner object
P.getInt(); // P is dangling
}

}];
Expand Down

0 comments on commit e258bb3

Please sign in to comment.