diff options
Diffstat (limited to 'include/clang/ASTMatchers/ASTMatchers.h')
-rw-r--r-- | include/clang/ASTMatchers/ASTMatchers.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index f42ac5b701..73ae8fb244 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -4118,6 +4118,26 @@ AST_MATCHER_P(IfStmt, hasConditionVariableStatement, InnerMatcher.matches(*DeclarationStatement, Finder, Builder); } +/// \brief Matches expressions with potential side effects other than producing +/// a value, such as a calling a function, throwing an exception, or reading a +/// volatile variable. +/// +/// Given +/// \code +/// void f(int& a, int b, volatile int c) { +/// call(); +/// a = 0; +/// a; +/// b; +/// c; +/// } +/// \endcode +/// expr(hasSideEffects()) +/// matches 'call()', 'a = 0', 'c', but not '0', 'a', 'b'. +AST_MATCHER(Expr, hasSideEffects) { + return Node.HasSideEffects(Finder->getASTContext()); +} + /// Matches the index expression of an array subscript expression. /// /// Given |