[clang] [clang][docs] Update the gsl::Pointer/Owner attr doc (PR #96908)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 27 06:43:32 PDT 2024
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/96908
- Fix some errors in the snippet;
- update the code snippet to reflect the current implementation status in clang;
>From 8da371ef1450852e3dede28b1f1dcb7c27ede530 Mon Sep 17 00:00:00 2001
From: Haojian Wu <hokein.wu at gmail.com>
Date: Thu, 27 Jun 2024 15:39:35 +0200
Subject: [PATCH] [clang][docs] Update the gsl::Pointer/Owner attr doc
- Fix some errors in the snippet;
- update the code snippet to reflect the current implementation status
in clang;
---
clang/include/clang/Basic/AttrDocs.td | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td
index 8d8f058281684..ab4bd003541fa 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -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.
@@ -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
}
}];
More information about the cfe-commits
mailing list