[clang-tools-extra] r363270 - [clang-tidy] Made abseil-upgrade-duration-conversions tests pass on c++17
Dmitri Gribenko via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 13 07:27:54 PDT 2019
Author: gribozavr
Date: Thu Jun 13 07:27:54 2019
New Revision: 363270
URL: http://llvm.org/viewvc/llvm-project?rev=363270&view=rev
Log:
[clang-tidy] Made abseil-upgrade-duration-conversions tests pass on c++17
Summary: Made abseil-upgrade-duration-conversions tests pass on c++17
Reviewers: hokein, gribozavr
Reviewed By: gribozavr
Subscribers: xazax.hun, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D63262
Patch by Johan Vikström.
Modified:
clang-tools-extra/trunk/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/abseil-upgrade-duration-conversions.cpp
Modified: clang-tools-extra/trunk/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp?rev=363270&r1=363269&r2=363270&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp Thu Jun 13 07:27:54 2019
@@ -40,7 +40,8 @@ void UpgradeDurationConversionsCheck::re
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 @@ void UpgradeDurationConversionsCheck::re
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 @@ void UpgradeDurationConversionsCheck::re
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 @@ void UpgradeDurationConversionsCheck::re
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 @@ void UpgradeDurationConversionsCheck::re
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 @@ void UpgradeDurationConversionsCheck::ch
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
Modified: clang-tools-extra/trunk/test/clang-tidy/abseil-upgrade-duration-conversions.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/abseil-upgrade-duration-conversions.cpp?rev=363270&r1=363269&r2=363270&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/abseil-upgrade-duration-conversions.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/abseil-upgrade-duration-conversions.cpp Thu Jun 13 07:27:54 2019
@@ -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;
More information about the cfe-commits
mailing list