[clang] [clang][docs] Update the gsl::Pointer/Owner attr doc (PR #96908)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 27 06:44:10 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Haojian Wu (hokein)
<details>
<summary>Changes</summary>
- Fix some errors in the snippet;
- update the code snippet to reflect the current implementation status in clang;
---
Full diff: https://github.com/llvm/llvm-project/pull/96908.diff
1 Files Affected:
- (modified) clang/include/clang/Basic/AttrDocs.td (+4-7)
``````````diff
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
}
}];
``````````
</details>
https://github.com/llvm/llvm-project/pull/96908
More information about the cfe-commits
mailing list