Skip to content

[clang][docs] Update the gsl::Pointer/Owner attr doc #96908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

hokein
Copy link
Collaborator

@hokein hokein commented Jun 27, 2024

  • Fix some errors in the snippet;
  • update the code snippet to reflect the current implementation status in clang;

- Fix some errors in the snippet;
- update the code snippet to reflect the current implementation status
  in clang;
@hokein hokein requested a review from Xazax-hun June 27, 2024 13:43
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jun 27, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 27, 2024

@llvm/pr-subscribers-clang

Author: Haojian Wu (hokein)

Changes
  • 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 --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
   }
 
 }];

@hokein hokein merged commit e258bb3 into llvm:main Jun 27, 2024
9 of 10 checks passed
@hokein hokein deleted the update-gsl-attr-doc branch June 27, 2024 16:53
lravenclaw pushed a commit to lravenclaw/llvm-project that referenced this pull request Jul 3, 2024
- Fix some errors in the snippet;
- update the code snippet to reflect the current implementation status
in clang;
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
- Fix some errors in the snippet;
- update the code snippet to reflect the current implementation status
in clang;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants