forked from OSchip/llvm-project
Fix skip-invisible with overloaded method calls
This commit is contained in:
parent
5e9392deaf
commit
04ed532ef0
|
@ -2931,8 +2931,10 @@ Expr *Expr::IgnoreUnlessSpelledInSource() {
|
|||
continue;
|
||||
}
|
||||
if (auto *PE = dyn_cast<ParenExpr>(ExprNode)) {
|
||||
E = PE;
|
||||
continue;
|
||||
if (PE->getSourceRange() == C->getSourceRange()) {
|
||||
E = PE;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ExprNode = ExprNode->IgnoreParenImpCasts();
|
||||
if (ExprNode->getSourceRange() == SR)
|
||||
|
|
|
@ -265,6 +265,9 @@ TEST(Traverse, IgnoreUnlessSpelledInSourceVars) {
|
|||
struct String
|
||||
{
|
||||
String(const char*, int = -1) {}
|
||||
|
||||
int overloaded() const;
|
||||
int& overloaded();
|
||||
};
|
||||
|
||||
void stringConstruct()
|
||||
|
@ -273,6 +276,12 @@ void stringConstruct()
|
|||
s = "bar";
|
||||
}
|
||||
|
||||
void overloadCall()
|
||||
{
|
||||
String s = "foo";
|
||||
(s).overloaded();
|
||||
}
|
||||
|
||||
struct C1 {};
|
||||
struct C2 { operator C1(); };
|
||||
|
||||
|
@ -331,6 +340,46 @@ FunctionDecl 'stringConstruct'
|
|||
)cpp");
|
||||
}
|
||||
|
||||
{
|
||||
auto FN =
|
||||
ast_matchers::match(functionDecl(hasName("overloadCall")).bind("fn"),
|
||||
AST->getASTContext());
|
||||
EXPECT_EQ(FN.size(), 1u);
|
||||
|
||||
EXPECT_EQ(dumpASTString(TK_AsIs, FN[0].getNodeAs<Decl>("fn")),
|
||||
R"cpp(
|
||||
FunctionDecl 'overloadCall'
|
||||
`-CompoundStmt
|
||||
|-DeclStmt
|
||||
| `-VarDecl 's'
|
||||
| `-ExprWithCleanups
|
||||
| `-CXXConstructExpr
|
||||
| `-MaterializeTemporaryExpr
|
||||
| `-ImplicitCastExpr
|
||||
| `-CXXConstructExpr
|
||||
| |-ImplicitCastExpr
|
||||
| | `-StringLiteral
|
||||
| `-CXXDefaultArgExpr
|
||||
`-CXXMemberCallExpr
|
||||
`-MemberExpr
|
||||
`-ParenExpr
|
||||
`-DeclRefExpr 's'
|
||||
)cpp");
|
||||
|
||||
EXPECT_EQ(dumpASTString(TK_IgnoreUnlessSpelledInSource,
|
||||
FN[0].getNodeAs<Decl>("fn")),
|
||||
R"cpp(
|
||||
FunctionDecl 'overloadCall'
|
||||
`-CompoundStmt
|
||||
|-DeclStmt
|
||||
| `-VarDecl 's'
|
||||
| `-StringLiteral
|
||||
`-CXXMemberCallExpr
|
||||
`-MemberExpr
|
||||
`-DeclRefExpr 's'
|
||||
)cpp");
|
||||
}
|
||||
|
||||
{
|
||||
auto FN = ast_matchers::match(
|
||||
functionDecl(hasName("conversionOperator"),
|
||||
|
|
Loading…
Reference in New Issue