Skip to content

Commit e258bb3

Browse files
authored
[clang][docs] Update the gsl::Pointer/Owner attr doc (llvm#96908)
- Fix some errors in the snippet; - update the code snippet to reflect the current implementation status in clang;
1 parent aa3589f commit e258bb3

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

clang/include/clang/Basic/AttrDocs.td

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6585,7 +6585,8 @@ like pointers to an object of type ``T``:
65856585
private:
65866586
int *valuePointer;
65876587
public:
6588-
int *getInt() { return &valuePointer; }
6588+
IntPointer(const IntOwner&);
6589+
int *getInt() { return valuePointer; }
65896590
};
65906591

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

66036604
int f() {
6604-
IntPointer P;
6605-
if (true) {
6606-
IntOwner O(7);
6607-
P = IntPointer(O); // P "points into" O
6608-
} // P is dangling
6609-
return P.get(); // error: Using a dangling Pointer.
6605+
IntPointer P(IntOwner{}); // P "points into" a temporary IntOwner object
6606+
P.getInt(); // P is dangling
66106607
}
66116608

66126609
}];

0 commit comments

Comments
 (0)