forked from OSchip/llvm-project
[clang-tidy] Fixed abseil-time-subtraction to work on C++17
Summary: Fixed abseil-time-subtraction to work on C++17 Reviewers: hokein, gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63261 Patch by Johan Vikström. llvm-svn: 363272
This commit is contained in:
parent
8f30e322ab
commit
0030306555
|
@ -29,33 +29,52 @@ static bool InsideMacroDefinition(const MatchFinder::MatchResult &Result,
|
||||||
|
|
||||||
static bool isConstructorAssignment(const MatchFinder::MatchResult &Result,
|
static bool isConstructorAssignment(const MatchFinder::MatchResult &Result,
|
||||||
const Expr *Node) {
|
const Expr *Node) {
|
||||||
|
// For C++14 and earlier there are elidable constructors that must be matched
|
||||||
|
// in hasParent. The elidable constructors do not exist in C++17 and later and
|
||||||
|
// therefore an additional check that does not match against the elidable
|
||||||
|
// constructors are needed for this case.
|
||||||
return selectFirst<const Expr>(
|
return selectFirst<const Expr>(
|
||||||
"e", match(expr(hasParent(materializeTemporaryExpr(hasParent(
|
"e",
|
||||||
cxxConstructExpr(hasParent(exprWithCleanups(
|
match(expr(anyOf(
|
||||||
hasParent(varDecl()))))))))
|
callExpr(hasParent(materializeTemporaryExpr(hasParent(
|
||||||
.bind("e"),
|
cxxConstructExpr(hasParent(exprWithCleanups(
|
||||||
*Node, *Result.Context)) != nullptr;
|
hasParent(varDecl()))))))))
|
||||||
|
.bind("e"),
|
||||||
|
callExpr(hasParent(varDecl())).bind("e"))),
|
||||||
|
*Node, *Result.Context)) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isArgument(const MatchFinder::MatchResult &Result,
|
static bool isArgument(const MatchFinder::MatchResult &Result,
|
||||||
const Expr *Node) {
|
const Expr *Node) {
|
||||||
|
// For the same reason as in isConstructorAssignment two AST shapes need to be
|
||||||
|
// matched here.
|
||||||
return selectFirst<const Expr>(
|
return selectFirst<const Expr>(
|
||||||
"e",
|
"e",
|
||||||
match(expr(hasParent(
|
match(
|
||||||
materializeTemporaryExpr(hasParent(cxxConstructExpr(
|
expr(anyOf(
|
||||||
hasParent(callExpr()),
|
expr(hasParent(materializeTemporaryExpr(
|
||||||
unless(hasParent(cxxOperatorCallExpr())))))))
|
hasParent(cxxConstructExpr(
|
||||||
.bind("e"),
|
hasParent(callExpr()),
|
||||||
*Node, *Result.Context)) != nullptr;
|
unless(hasParent(cxxOperatorCallExpr())))))))
|
||||||
|
.bind("e"),
|
||||||
|
expr(hasParent(callExpr()),
|
||||||
|
unless(hasParent(cxxOperatorCallExpr())))
|
||||||
|
.bind("e"))),
|
||||||
|
*Node, *Result.Context)) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isReturn(const MatchFinder::MatchResult &Result, const Expr *Node) {
|
static bool isReturn(const MatchFinder::MatchResult &Result, const Expr *Node) {
|
||||||
|
// For the same reason as in isConstructorAssignment two AST shapes need to be
|
||||||
|
// matched here.
|
||||||
return selectFirst<const Expr>(
|
return selectFirst<const Expr>(
|
||||||
"e", match(expr(hasParent(materializeTemporaryExpr(hasParent(
|
"e",
|
||||||
cxxConstructExpr(hasParent(exprWithCleanups(
|
match(expr(anyOf(
|
||||||
hasParent(returnStmt()))))))))
|
expr(hasParent(materializeTemporaryExpr(hasParent(
|
||||||
.bind("e"),
|
cxxConstructExpr(hasParent(exprWithCleanups(
|
||||||
*Node, *Result.Context)) != nullptr;
|
hasParent(returnStmt()))))))))
|
||||||
|
.bind("e"),
|
||||||
|
expr(hasParent(returnStmt())).bind("e"))),
|
||||||
|
*Node, *Result.Context)) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool parensRequired(const MatchFinder::MatchResult &Result,
|
static bool parensRequired(const MatchFinder::MatchResult &Result,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// RUN: %check_clang_tidy -std=c++11,c++14 %s abseil-time-subtraction %t -- -- -I %S/Inputs
|
// RUN: %check_clang_tidy -std=c++11-or-later %s abseil-time-subtraction %t -- -- -I %S/Inputs
|
||||||
// FIXME: Fix the checker to work in C++17 mode.
|
// FIXME: Fix the checker to work in C++17 mode.
|
||||||
|
|
||||||
#include "absl/time/time.h"
|
#include "absl/time/time.h"
|
||||||
|
|
Loading…
Reference in New Issue