diff options
author | Haojian Wu <hokein@google.com> | 2016-09-26 16:01:52 +0000 |
---|---|---|
committer | Haojian Wu <hokein@google.com> | 2016-09-26 16:01:52 +0000 |
commit | b2c1023a57dfe16e64e14fcd207a82f1571345a1 (patch) | |
tree | f949a8813714a27ff99640a4b6ed881d2936ad6a /include/clang/ASTMatchers | |
parent | 1f6e70072ee98bce99c82e8bfa6c251666b37b97 (diff) |
[ASTMatcher] Add isStaticStorageClass matcher for varDecl and functionDecl.
Reviewers: klimek
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D24821
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@282415 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/ASTMatchers')
-rw-r--r-- | include/clang/ASTMatchers/ASTMatchers.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index fdef3bd70b..a45b0bebca 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -3387,6 +3387,24 @@ AST_POLYMORPHIC_MATCHER(isExternC, AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, return Node.isExternC(); } +/// \brief Matches variable/function declarations that have static storage class +/// (with "static" key word) written in the source. +/// +/// Given: +/// \code +/// static void f() {} +/// static int i = 0; +/// \endcode +/// functionDecl(isStaticStorageClass()) +/// matches the function declaration f. +/// varDecl(isStaticStorageClass()) +/// matches the variable declaration i. +AST_POLYMORPHIC_MATCHER(isStaticStorageClass, + AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, + VarDecl)) { + return Node.getStorageClass() == SC_Static; +} + /// \brief Matches deleted function declarations. /// /// Given: |