[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 19 12:10:00 PST 2018


aaron.ballman added a comment.

In https://reviews.llvm.org/D42213#982256, @MaskRay wrote:

> I am also not sure about this function:  line 3548
>
>   /// \brief Matches \c FunctionDecls and \c FunctionProtoTypes that have a
>   /// specific parameter count.
>   ///
>   /// Given
>   /// \code
>   ///   void f(int i) {}
>   ///   void g(int i, int j) {}
>   ///   void h(int i, int j);
>   ///   void j(int i);
>   ///   void k(int x, int y, int z, ...);
>   /// \endcode
>   /// functionDecl(parameterCountIs(2))
>   ///   matches void g(int i, int j) {}
>   /// functionProtoType(parameterCountIs(2))
>   ///   matches void h(int i, int j)
>   /// functionProtoType(parameterCountIs(3))
>   ///   matches void k(int x, int y, int z, ...);
>   AST_POLYMORPHIC_MATCHER_P(parameterCountIs,
>                             AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
>                                                             FunctionProtoType),
>   }
>
>
> Both `functionDecl` and `functionProtoType` match these functions as long as the parameter count is matched.
>
>   % echo 'match functionDecl()'|clang-query =(printf 'void f(){}') -- -xc++
>   % echo 'match functionProtoType()'|clang-query =(printf 'void f(){}') -- -xc++
>


I'm not certain I'm following along. The quoted matcher is for `parameterCountIs()`, but the test code you've posted doesn't use that matcher. However, the quoted comment seems like it's wrong: `functionDecl(parameterCountIs(2))` should match both g() and h(), not just g(), I believe.


Repository:
  rC Clang

https://reviews.llvm.org/D42213





More information about the cfe-commits mailing list