Changeset View
Changeset View
Standalone View
Standalone View
include/clang/ASTMatchers/ASTMatchers.h
Show First 20 Lines • Show All 3,294 Lines • ▼ Show 20 Lines | |||||
AST_MATCHER_P( | AST_MATCHER_P( | ||||
VarDecl, hasInitializer, internal::Matcher<Expr>, | VarDecl, hasInitializer, internal::Matcher<Expr>, | ||||
InnerMatcher) { | InnerMatcher) { | ||||
const Expr *Initializer = Node.getAnyInitializer(); | const Expr *Initializer = Node.getAnyInitializer(); | ||||
return (Initializer != nullptr && | return (Initializer != nullptr && | ||||
InnerMatcher.matches(*Initializer, Finder, Builder)); | InnerMatcher.matches(*Initializer, Finder, Builder)); | ||||
} | } | ||||
/// \brief Matches a static variable with local scope. | |||||
/// | |||||
/// Example matches y (matcher = varDecl(isStaticLocal())) | |||||
/// \code | |||||
/// void f() { | |||||
/// int x; | |||||
/// static int y; | |||||
/// } | |||||
/// static int z; | |||||
/// \endcode | |||||
AST_MATCHER(VarDecl, isStaticLocal) { | |||||
return Node.isStaticLocal(); | |||||
} | |||||
/// Matches a variable declaration that has function scope and is a | /// Matches a variable declaration that has function scope and is a | ||||
/// non-static local variable. | /// non-static local variable. | ||||
/// | /// | ||||
/// Example matches x (matcher = varDecl(hasLocalStorage()) | /// Example matches x (matcher = varDecl(hasLocalStorage()) | ||||
/// \code | /// \code | ||||
/// void f() { | /// void f() { | ||||
/// int x; | /// int x; | ||||
/// static int y; | /// static int y; | ||||
▲ Show 20 Lines • Show All 2,922 Lines • Show Last 20 Lines |