forked from OSchip/llvm-project
Implements the thisExpr matcher.
Patch by Gabor Horvath. llvm-svn: 166477
This commit is contained in:
parent
5ed3900d77
commit
7fca93b428
|
@ -546,6 +546,18 @@ const internal::VariadicDynCastAllOfMatcher<
|
|||
Stmt,
|
||||
CXXConstructExpr> constructExpr;
|
||||
|
||||
/// \brief Matches implicit and explicit this expressions.
|
||||
///
|
||||
/// Example matches the implicit this expression in "return i".
|
||||
/// (matcher = thisExpr())
|
||||
/// \code
|
||||
/// struct foo {
|
||||
/// int i;
|
||||
/// int f() { return i; }
|
||||
/// };
|
||||
/// \endcode
|
||||
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXThisExpr> thisExpr;
|
||||
|
||||
/// \brief Matches nodes where temporaries are created.
|
||||
///
|
||||
/// Example matches FunctionTakesString(GetStringByValue())
|
||||
|
|
|
@ -1333,6 +1333,13 @@ TEST(Matcher, ConstructorArgumentCount) {
|
|||
Constructor1Arg));
|
||||
}
|
||||
|
||||
TEST(Matcher,ThisExpr) {
|
||||
EXPECT_TRUE(
|
||||
matches("struct X { int a; int f () { return a; } };", thisExpr()));
|
||||
EXPECT_TRUE(
|
||||
notMatches("struct X { int f () { int a; return a; } };", thisExpr()));
|
||||
}
|
||||
|
||||
TEST(Matcher, BindTemporaryExpression) {
|
||||
StatementMatcher TempExpression = bindTemporaryExpr();
|
||||
|
||||
|
|
Loading…
Reference in New Issue