forked from OSchip/llvm-project
[ASTMatchers] Fix bug in `hasUnaryOperand`
Currently, `hasUnaryOperand` fails for the overloaded `operator*`. This patch fixes the bug and adds tests for this case. Differential Revision: https://reviews.llvm.org/D104389
This commit is contained in:
parent
54384d1723
commit
439c920694
|
@ -2102,6 +2102,8 @@ equivalentUnaryOperator<CXXOperatorCallExpr>(const CXXOperatorCallExpr &Node) {
|
|||
return UO_Minus;
|
||||
case OO_Amp:
|
||||
return UO_AddrOf;
|
||||
case OO_Star:
|
||||
return UO_Deref;
|
||||
case OO_Tilde:
|
||||
return UO_Not;
|
||||
case OO_Exclaim:
|
||||
|
|
|
@ -1893,6 +1893,23 @@ void plusIntOperator()
|
|||
cxxOperatorCallExpr(
|
||||
forFunction(functionDecl(hasName("plusIntOperator"))),
|
||||
hasOperatorName("+"), hasUnaryOperand(expr())))));
|
||||
|
||||
Code = R"cpp(
|
||||
struct HasOpArrow
|
||||
{
|
||||
int& operator*();
|
||||
};
|
||||
void foo()
|
||||
{
|
||||
HasOpArrow s1;
|
||||
*s1;
|
||||
}
|
||||
)cpp";
|
||||
|
||||
EXPECT_TRUE(
|
||||
matches(Code, traverse(TK_IgnoreUnlessSpelledInSource,
|
||||
cxxOperatorCallExpr(hasOperatorName("*"),
|
||||
hasUnaryOperand(expr())))));
|
||||
}
|
||||
|
||||
TEST(Matcher, UnaryOperatorTypes) {
|
||||
|
|
Loading…
Reference in New Issue