[clang] 3e315ba - Deprecate the hasDefaultArgument matcher

Stephen Kelly via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 10 12:48:58 PST 2019


Author: Stephen Kelly
Date: 2019-12-10T20:48:45Z
New Revision: 3e315ba2547cbbfd6055e38bbca03f4d11bacbea

URL: https://github.com/llvm/llvm-project/commit/3e315ba2547cbbfd6055e38bbca03f4d11bacbea
DIFF: https://github.com/llvm/llvm-project/commit/3e315ba2547cbbfd6055e38bbca03f4d11bacbea.diff

LOG: Deprecate the hasDefaultArgument matcher

Summary:
It doesn't provide a way to match on the contents of the default
argumment.  Rather than give it that capability, make it deprecated and
recomment the use of hasInitializer instead.

Reviewers: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71166

Added: 
    

Modified: 
    clang/include/clang/ASTMatchers/ASTMatchers.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 9c0aae2886fc..c3399db95b89 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -6544,6 +6544,20 @@ AST_MATCHER(NamedDecl, hasExternalFormalLinkage) {
 /// void x(int val) {}
 /// void y(int val = 0) {}
 /// \endcode
+///
+/// Deprecated. Use hasInitializer() instead to be able to
+/// match on the contents of the default argument.  For example:
+///
+/// \code
+/// void x(int val = 7) {}
+/// void y(int val = 42) {}
+/// \endcode
+/// parmVarDecl(hasInitializer(integerLiteral(equals(42))))
+///   matches the parameter of y
+///
+/// A matcher such as
+///   parmVarDecl(hasInitializer(anything()))
+/// is equivalent to parmVarDecl(hasDefaultArgument()).
 AST_MATCHER(ParmVarDecl, hasDefaultArgument) {
   return Node.hasDefaultArg();
 }


        


More information about the cfe-commits mailing list