[clang] e258bb3 - [clang][docs] Update the gsl::Pointer/Owner attr doc (#96908)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 27 09:53:59 PDT 2024
Author: Haojian Wu
Date: 2024-06-27T18:53:54+02:00
New Revision: e258bb38dc8f00cc366df877d0e6f869657b7a8b
URL: https://github.com/llvm/llvm-project/commit/e258bb38dc8f00cc366df877d0e6f869657b7a8b
DIFF: https://github.com/llvm/llvm-project/commit/e258bb38dc8f00cc366df877d0e6f869657b7a8b.diff
LOG: [clang][docs] Update the gsl::Pointer/Owner attr doc (#96908)
- Fix some errors in the snippet;
- update the code snippet to reflect the current implementation status
in clang;
Added:
Modified:
clang/include/clang/Basic/AttrDocs.td
Removed:
################################################################################
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