diff options
author | Shuai Wang <shuaiwang@google.com> | 2018-09-11 02:23:35 +0000 |
---|---|---|
committer | Shuai Wang <shuaiwang@google.com> | 2018-09-11 02:23:35 +0000 |
commit | 5066ab369d3bf10e56202549c7e414a59a78d586 (patch) | |
tree | d9f4db4f06126e40fd784d06e8244181f0d138e6 /clang-tools-extra/clang-tidy/utils/ExprMutationAnalyzer.cpp | |
parent | 4ec5a9159bc9e4b98010b3688a0c79a4a8d75402 (diff) | |
download | bcm5719-llvm-5066ab369d3bf10e56202549c7e414a59a78d586.tar.gz bcm5719-llvm-5066ab369d3bf10e56202549c7e414a59a78d586.zip |
Revert "Revert "[clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer""
This is the same as D50619 plus fixes for buildbot failures on windows.
The test failures on windows are caused by -fdelayed-template-parsing
and is fixed by forcing -fno-delayed-template-parsing on test cases that
requires AST for uninstantiated templates.
llvm-svn: 341891
Diffstat (limited to 'clang-tools-extra/clang-tidy/utils/ExprMutationAnalyzer.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/utils/ExprMutationAnalyzer.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/clang-tools-extra/clang-tidy/utils/ExprMutationAnalyzer.cpp b/clang-tools-extra/clang-tidy/utils/ExprMutationAnalyzer.cpp index adf4095d009..f979e97a03d 100644 --- a/clang-tools-extra/clang-tidy/utils/ExprMutationAnalyzer.cpp +++ b/clang-tools-extra/clang-tidy/utils/ExprMutationAnalyzer.cpp @@ -145,11 +145,16 @@ const Stmt *ExprMutationAnalyzer::findDirectMutation(const Expr *Exp) { hasUnaryOperand(equalsNode(Exp))); // Invoking non-const member function. + // A member function is assumed to be non-const when it is unresolved. const auto NonConstMethod = cxxMethodDecl(unless(isConst())); const auto AsNonConstThis = expr(anyOf(cxxMemberCallExpr(callee(NonConstMethod), on(equalsNode(Exp))), cxxOperatorCallExpr(callee(NonConstMethod), - hasArgument(0, equalsNode(Exp))))); + hasArgument(0, equalsNode(Exp))), + callExpr(callee(expr(anyOf( + unresolvedMemberExpr(hasObjectExpression(equalsNode(Exp))), + cxxDependentScopeMemberExpr( + hasObjectExpression(equalsNode(Exp))))))))); // Taking address of 'Exp'. // We're assuming 'Exp' is mutated as soon as its address is taken, though in @@ -165,10 +170,16 @@ const Stmt *ExprMutationAnalyzer::findDirectMutation(const Expr *Exp) { unless(hasParent(arraySubscriptExpr())), has(equalsNode(Exp))); // Used as non-const-ref argument when calling a function. + // An argument is assumed to be non-const-ref when the function is unresolved. const auto NonConstRefParam = forEachArgumentWithParam( equalsNode(Exp), parmVarDecl(hasType(nonConstReferenceType()))); - const auto AsNonConstRefArg = - anyOf(callExpr(NonConstRefParam), cxxConstructExpr(NonConstRefParam)); + const auto AsNonConstRefArg = anyOf( + callExpr(NonConstRefParam), cxxConstructExpr(NonConstRefParam), + callExpr(callee(expr(anyOf(unresolvedLookupExpr(), unresolvedMemberExpr(), + cxxDependentScopeMemberExpr(), + hasType(templateTypeParmType())))), + hasAnyArgument(equalsNode(Exp))), + cxxUnresolvedConstructExpr(hasAnyArgument(equalsNode(Exp)))); // Captured by a lambda by reference. // If we're initializing a capture with 'Exp' directly then we're initializing @@ -195,9 +206,12 @@ const Stmt *ExprMutationAnalyzer::findDirectMutation(const Expr *Exp) { const Stmt *ExprMutationAnalyzer::findMemberMutation(const Expr *Exp) { // Check whether any member of 'Exp' is mutated. - const auto MemberExprs = match( - findAll(memberExpr(hasObjectExpression(equalsNode(Exp))).bind("expr")), - Stm, Context); + const auto MemberExprs = + match(findAll(expr(anyOf(memberExpr(hasObjectExpression(equalsNode(Exp))), + cxxDependentScopeMemberExpr( + hasObjectExpression(equalsNode(Exp))))) + .bind("expr")), + Stm, Context); return findExprMutation(MemberExprs); } |