[clang-tools-extra] r348842 - Use the standard Duration factory matcher

Jonas Toth via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 11 04:45:51 PST 2018


Author: jonastoth
Date: Tue Dec 11 04:45:51 2018
New Revision: 348842

URL: http://llvm.org/viewvc/llvm-project?rev=348842&view=rev
Log:
Use the standard Duration factory matcher

Summary: A new check came in over the weekend; it should use our existing infrastructure for matching `absl::Duration` factories.

Patch by hwright.

Reviewers: JonasToth

Reviewed By: JonasToth

Subscribers: astrelni

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D55541

Modified:
    clang-tools-extra/trunk/clang-tidy/abseil/UpgradeDurationConversionsCheck.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=348842&r1=348841&r2=348842&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp Tue Dec 11 04:45:51 2018
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "UpgradeDurationConversionsCheck.h"
+#include "DurationRewriter.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
@@ -102,10 +103,7 @@ void UpgradeDurationConversionsCheck::re
           anyOf(hasCastKind(CK_UserDefinedConversion),
                 has(implicitCastExpr(hasCastKind(CK_UserDefinedConversion)))),
           hasParent(callExpr(
-              callee(functionDecl(
-                  hasAnyName("::absl::Nanoseconds", "::absl::Microseconds",
-                             "::absl::Milliseconds", "::absl::Seconds",
-                             "::absl::Minutes", "::absl::Hours"),
+              callee(functionDecl(DurationFactoryFunction(),
                   unless(hasParent(functionTemplateDecl())))),
               hasArgument(0, expr().bind("arg"))))),
       this);




More information about the cfe-commits mailing list