================ @@ -330,35 +377,46 @@ AST_POLYMORPHIC_MATCHER_P(isExpandedFromMacro, /// Matches declarations. /// -/// Examples matches \c X, \c C, and the friend declaration inside \c C; +/// Given /// \code /// void X(); /// class C { -/// friend X; +/// friend void X(); /// }; /// \endcode +/// \compile_args{-std=c++} +/// The matcher \matcher{decl()} +/// matches \match{void X()}, \match{type=name;count=2$C} +/// and \match{count=2$friend void X()}. ---------------- 5chmidti wrote:
``` |-FunctionDecl <line:1:1, col:8> col:6 X 'void ()' `-CXXRecordDecl <line:2:1, line:4:1> line:2:7 class C definition |-DefinitionData pass_in_registers empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init | |-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param | |-MoveConstructor exists simple trivial needs_implicit | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param | |-MoveAssignment exists simple trivial needs_implicit | `-Destructor simple irrelevant trivial needs_implicit |-CXXRecordDecl <col:1, col:7> col:7 implicit class C `-FriendDecl <line:3:5, col:19> col:17 `-FunctionDecl parent 0xf23a388 prev 0xf284370 <col:5, col:19> col:17 friend X 'void ()' ``` > Can you explain `\match{type=name;count=2$C}`? That is the `implicit class C` in the AST above. I couldn't access it from the top-level `C` and I couldn't find a way from the `implicit class C` back to the top-level one, so I don't know how to call it. I thought it would be a decl but not a definition, however, `getDefinition` returns a `nullptr` for the `implicit class C`. > should we add a comment explaining that other match? Certainly. I'll read the documentation again to see if there are more cases like this that could be improved as well. https://github.com/llvm/llvm-project/pull/94248 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits