[clang] [clang][NFC] Fix example code for memberPointerType() AST matcher (PR #109404)

Carlos Galvez via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 20 04:33:44 PDT 2024


https://github.com/carlosgalvezp created https://github.com/llvm/llvm-project/pull/109404

The example code doesn't compile otherwise.

>From f598e98d4deb66a313b7f944cb96df04bc4b91a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20G=C3=A1lvez?= <carlos.galvez at zenseact.com>
Date: Fri, 20 Sep 2024 11:32:07 +0000
Subject: [PATCH] [clang][NFC] Fix example code for memberPointerType() AST
 matcher

The example code doesn't compile otherwise.
---
 clang/docs/LibASTMatchersReference.html       | 6 ++----
 clang/include/clang/ASTMatchers/ASTMatchers.h | 4 ++--
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html
index a16b9c44ef0eab..30695efc3e304e 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -2675,8 +2675,8 @@ <h2 id="decl-matchers">Node Matchers</h2>
 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('memberPointerType0')"><a name="memberPointerType0Anchor">memberPointerType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>...</td></tr>
 <tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types.
 Given
-  struct A { int i; }
-  A::* ptr = A::i;
+  struct A { int i; };
+  int A::* ptr = &A::i;
 memberPointerType()
   matches "A::* ptr"
 </pre></td></tr>
@@ -10659,5 +10659,3 @@ <h2 id="traversal-matchers">AST Traversal Matchers</h2>
 </div>
 </body>
 </html>
-
-
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index f1c72efc238784..61877c435208fa 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -7327,8 +7327,8 @@ extern const AstTypeMatcher<BlockPointerType> blockPointerType;
 /// Matches member pointer types.
 /// Given
 /// \code
-///   struct A { int i; }
-///   A::* ptr = A::i;
+///   struct A { int i; };
+///   int A::* ptr = &A::i;
 /// \endcode
 /// memberPointerType()
 ///   matches "A::* ptr"



More information about the cfe-commits mailing list