[clang-tools-extra] r352088 - [clang-tidy] Rename the absl duration helper functions; NFC

Hyrum Wright via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 24 11:23:50 PST 2019


Author: hwright
Date: Thu Jan 24 11:23:50 2019
New Revision: 352088

URL: http://llvm.org/viewvc/llvm-project?rev=352088&view=rev
Log:
[clang-tidy] Rename the absl duration helper functions; NFC

Modified:
    clang-tools-extra/trunk/clang-tidy/abseil/DurationComparisonCheck.cpp
    clang-tools-extra/trunk/clang-tidy/abseil/DurationConversionCastCheck.cpp
    clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
    clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
    clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h
    clang-tools-extra/trunk/clang-tidy/abseil/DurationSubtractionCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationComparisonCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationComparisonCheck.cpp?rev=352088&r1=352087&r2=352088&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationComparisonCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationComparisonCheck.cpp Thu Jan 24 11:23:50 2019
@@ -34,7 +34,7 @@ void DurationComparisonCheck::registerMa
 void DurationComparisonCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *Binop = Result.Nodes.getNodeAs<BinaryOperator>("binop");
 
-  llvm::Optional<DurationScale> Scale = getScaleForInverse(
+  llvm::Optional<DurationScale> Scale = getScaleForDurationInverse(
       Result.Nodes.getNodeAs<FunctionDecl>("function_decl")->getName());
   if (!Scale)
     return;

Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationConversionCastCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationConversionCastCheck.cpp?rev=352088&r1=352087&r2=352088&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationConversionCastCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationConversionCastCheck.cpp Thu Jan 24 11:23:50 2019
@@ -44,14 +44,15 @@ void DurationConversionCastCheck::check(
   const auto *Arg = Result.Nodes.getNodeAs<Expr>("arg");
   StringRef ConversionFuncName = FuncDecl->getName();
 
-  llvm::Optional<DurationScale> Scale = getScaleForInverse(ConversionFuncName);
+  llvm::Optional<DurationScale> Scale =
+      getScaleForDurationInverse(ConversionFuncName);
   if (!Scale)
     return;
 
   // Casting a double to an integer.
   if (MatchedCast->getTypeAsWritten()->isIntegerType() &&
       ConversionFuncName.contains("Double")) {
-    llvm::StringRef NewFuncName = getInverseForScale(*Scale).second;
+    llvm::StringRef NewFuncName = getDurationInverseForScale(*Scale).second;
 
     diag(MatchedCast->getBeginLoc(),
          "duration should be converted directly to an integer rather than "
@@ -66,7 +67,7 @@ void DurationConversionCastCheck::check(
   // Casting an integer to a double.
   if (MatchedCast->getTypeAsWritten()->isRealFloatingType() &&
       ConversionFuncName.contains("Int64")) {
-    llvm::StringRef NewFuncName = getInverseForScale(*Scale).first;
+    llvm::StringRef NewFuncName = getDurationInverseForScale(*Scale).first;
 
     diag(MatchedCast->getBeginLoc(), "duration should be converted directly to "
                                      "a floating-piont number rather than "

Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp?rev=352088&r1=352087&r2=352088&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp Thu Jan 24 11:23:50 2019
@@ -209,7 +209,7 @@ void DurationFactoryScaleCheck::check(co
       diag(Call->getBeginLoc(), "internal duration scaling can be removed")
           << FixItHint::CreateReplacement(
                  Call->getSourceRange(),
-                 (llvm::Twine(getFactoryForScale(*NewScale)) + "(" +
+                 (llvm::Twine(getDurationFactoryForScale(*NewScale)) + "(" +
                   tooling::fixit::getText(*Remainder, *Result.Context) + ")")
                      .str());
     }
@@ -222,7 +222,7 @@ void DurationFactoryScaleCheck::check(co
     diag(Call->getBeginLoc(), "internal duration scaling can be removed")
         << FixItHint::CreateReplacement(
                Call->getSourceRange(),
-               (llvm::Twine(getFactoryForScale(*NewScale)) + "(" +
+               (llvm::Twine(getDurationFactoryForScale(*NewScale)) + "(" +
                 tooling::fixit::getText(*Remainder, *Result.Context) + ")")
                    .str());
   }

Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp?rev=352088&r1=352087&r2=352088&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp Thu Jan 24 11:23:50 2019
@@ -37,7 +37,7 @@ truncateIfIntegral(const FloatingLiteral
 }
 
 const std::pair<llvm::StringRef, llvm::StringRef> &
-getInverseForScale(DurationScale Scale) {
+getDurationInverseForScale(DurationScale Scale) {
   static const llvm::IndexedMap<std::pair<llvm::StringRef, llvm::StringRef>,
                                 DurationScale2IndexFunctor>
       InverseMap = []() {
@@ -71,7 +71,7 @@ static llvm::Optional<std::string>
 rewriteInverseDurationCall(const MatchFinder::MatchResult &Result,
                            DurationScale Scale, const Expr &Node) {
   const std::pair<llvm::StringRef, llvm::StringRef> &InverseFunctions =
-      getInverseForScale(Scale);
+      getDurationInverseForScale(Scale);
   if (const auto *MaybeCallArg = selectFirst<const Expr>(
           "e",
           match(callExpr(callee(functionDecl(hasAnyName(
@@ -85,7 +85,7 @@ rewriteInverseDurationCall(const MatchFi
 }
 
 /// Returns the factory function name for a given `Scale`.
-llvm::StringRef getFactoryForScale(DurationScale Scale) {
+llvm::StringRef getDurationFactoryForScale(DurationScale Scale) {
   switch (Scale) {
   case DurationScale::Hours:
     return "absl::Hours";
@@ -175,7 +175,7 @@ std::string simplifyDurationFactoryArg(c
   return tooling::fixit::getText(Node, *Result.Context).str();
 }
 
-llvm::Optional<DurationScale> getScaleForInverse(llvm::StringRef Name) {
+llvm::Optional<DurationScale> getScaleForDurationInverse(llvm::StringRef Name) {
   static const llvm::StringMap<DurationScale> ScaleMap(
       {{"ToDoubleHours", DurationScale::Hours},
        {"ToInt64Hours", DurationScale::Hours},
@@ -210,7 +210,7 @@ std::string rewriteExprFromNumberToDurat
   if (IsLiteralZero(Result, RootNode))
     return std::string("absl::ZeroDuration()");
 
-  return (llvm::Twine(getFactoryForScale(Scale)) + "(" +
+  return (llvm::Twine(getDurationFactoryForScale(Scale)) + "(" +
           simplifyDurationFactoryArg(Result, RootNode) + ")")
       .str();
 }

Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h?rev=352088&r1=352087&r2=352088&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h Thu Jan 24 11:23:50 2019
@@ -29,7 +29,7 @@ enum class DurationScale : std::uint8_t
 
 /// Given a `Scale`, return the appropriate factory function call for
 /// constructing a `Duration` for that scale.
-llvm::StringRef getFactoryForScale(DurationScale Scale);
+llvm::StringRef getDurationFactoryForScale(DurationScale Scale);
 
 // Determine if `Node` represents a literal floating point or integral zero.
 bool IsLiteralZero(const ast_matchers::MatchFinder::MatchResult &Result,
@@ -60,13 +60,13 @@ simplifyDurationFactoryArg(const ast_mat
 
 /// Given the name of an inverse Duration function (e.g., `ToDoubleSeconds`),
 /// return its `DurationScale`, or `None` if a match is not found.
-llvm::Optional<DurationScale> getScaleForInverse(llvm::StringRef Name);
+llvm::Optional<DurationScale> getScaleForDurationInverse(llvm::StringRef Name);
 
 /// Given a `Scale` return the fully qualified inverse functions for it.
 /// The first returned value is the inverse for `double`, and the second
 /// returned value is the inverse for `int64`.
 const std::pair<llvm::StringRef, llvm::StringRef> &
-getInverseForScale(DurationScale Scale);
+getDurationInverseForScale(DurationScale Scale);
 
 /// Assuming `Node` has type `double` or `int` representing a time interval of
 /// `Scale`, return the expression to make it a suitable `Duration`.

Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationSubtractionCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationSubtractionCheck.cpp?rev=352088&r1=352087&r2=352088&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationSubtractionCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationSubtractionCheck.cpp Thu Jan 24 11:23:50 2019
@@ -37,7 +37,8 @@ void DurationSubtractionCheck::check(con
   if (Binop->getExprLoc().isMacroID() || Binop->getExprLoc().isInvalid())
     return;
 
-  llvm::Optional<DurationScale> Scale = getScaleForInverse(FuncDecl->getName());
+  llvm::Optional<DurationScale> Scale =
+      getScaleForDurationInverse(FuncDecl->getName());
   if (!Scale)
     return;
 




More information about the cfe-commits mailing list