[PATCH] D63262: [clang-tidy] Made abseil-upgrade-duration-conversions tests pass on c++17
Johan Vikström via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 13 06:35:06 PDT 2019
jvikstrom created this revision.
jvikstrom added reviewers: hokein, gribozavr.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
Made abseil-upgrade-duration-conversions tests pass on c++17
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D63262
Files:
clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
clang-tools-extra/test/clang-tidy/abseil-upgrade-duration-conversions.cpp
Index: clang-tools-extra/test/clang-tidy/abseil-upgrade-duration-conversions.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/abseil-upgrade-duration-conversions.cpp
+++ clang-tools-extra/test/clang-tidy/abseil-upgrade-duration-conversions.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s abseil-upgrade-duration-conversions %t -- -- -I%S/Inputs
+// RUN: %check_clang_tidy -std=c++11-or-later %s abseil-upgrade-duration-conversions %t -- -- -I%S/Inputs
// FIXME: Fix the checker to work in C++17 mode.
using int64_t = long long;
Index: clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
+++ clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
@@ -40,7 +40,8 @@
callee(functionDecl(
hasParent(functionTemplateDecl()),
unless(hasTemplateArgument(0, refersToType(builtinType()))),
- hasAnyName("operator*=", "operator/=")))),
+ hasAnyName("operator*=", "operator/="))))
+ .bind("OuterExpr"),
this);
// Match expressions like `a.operator*=(b)` and `a.operator/=(b)` where `a`
@@ -52,7 +53,8 @@
hasParent(functionTemplateDecl()),
unless(hasTemplateArgument(0, refersToType(builtinType()))),
hasAnyName("operator*=", "operator/="))),
- argumentCountIs(1), hasArgument(0, expr().bind("arg"))),
+ argumentCountIs(1), hasArgument(0, expr().bind("arg")))
+ .bind("OuterExpr"),
this);
// Match expressions like `a * b`, `a / b`, `operator*(a, b)`, and
@@ -66,7 +68,8 @@
argumentCountIs(2),
hasArgument(0, expr(hasType(
cxxRecordDecl(hasName("::absl::Duration"))))),
- hasArgument(1, expr().bind("arg"))),
+ hasArgument(1, expr().bind("arg")))
+ .bind("OuterExpr"),
this);
// Match expressions like `a * b` and `operator*(a, b)` where `a` is not of a
@@ -77,8 +80,9 @@
unless(hasTemplateArgument(0, refersToType(builtinType()))),
hasName("::absl::operator*"))),
argumentCountIs(2), hasArgument(0, expr().bind("arg")),
- hasArgument(1, expr(hasType(cxxRecordDecl(
- hasName("::absl::Duration")))))),
+ hasArgument(1, expr(hasType(
+ cxxRecordDecl(hasName("::absl::Duration"))))))
+ .bind("OuterExpr"),
this);
// For the factory functions, we match only the non-templated overloads that
@@ -103,8 +107,9 @@
has(implicitCastExpr(hasCastKind(CK_UserDefinedConversion)))),
hasParent(callExpr(
callee(functionDecl(DurationFactoryFunction(),
- unless(hasParent(functionTemplateDecl())))),
- hasArgument(0, expr().bind("arg"))))),
+ unless(hasParent(functionTemplateDecl())))),
+ hasArgument(0, expr().bind("arg")))))
+ .bind("OuterExpr"),
this);
}
@@ -117,7 +122,10 @@
const auto *ArgExpr = Result.Nodes.getNodeAs<Expr>("arg");
SourceLocation Loc = ArgExpr->getBeginLoc();
- if (!match(isInTemplateInstantiation(), *ArgExpr, *Result.Context).empty()) {
+ const auto *OuterExpr = Result.Nodes.getNodeAs<Expr>("OuterExpr");
+
+ if (!match(isInTemplateInstantiation(), *OuterExpr, *Result.Context)
+ .empty()) {
if (MatchedTemplateLocations.count(Loc.getRawEncoding()) == 0) {
// For each location matched in a template instantiation, we check if the
// location can also be found in `MatchedTemplateLocations`. If it is not
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63262.204517.patch
Type: text/x-patch
Size: 3908 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190613/367c530f/attachment.bin>
More information about the cfe-commits
mailing list