[clang-tools-extra] 574dd60 - [clangd] Track tweaks that fail the apply stage

Kadir Cetinkaya via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 14 02:24:12 PDT 2020


Author: Kadir Cetinkaya
Date: 2020-09-14T11:24:02+02:00
New Revision: 574dd60547179a2c143ac14cdd6f5f5a40156d54

URL: https://github.com/llvm/llvm-project/commit/574dd60547179a2c143ac14cdd6f5f5a40156d54
DIFF: https://github.com/llvm/llvm-project/commit/574dd60547179a2c143ac14cdd6f5f5a40156d54.diff

LOG: [clangd] Track tweaks that fail the apply stage

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

Added: 
    

Modified: 
    clang-tools-extra/clangd/ClangdServer.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp
index a571ff56ce4c..27d1a2dc7cdc 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -536,9 +536,12 @@ void ClangdServer::enumerateTweaks(PathRef File, Range Sel,
 
 void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
                               Callback<Tweak::Effect> CB) {
-  // Tracks number of times a tweak has been applied.
+  // Tracks number of times a tweak has been attempted.
   static constexpr trace::Metric TweakAttempt(
       "tweak_attempt", trace::Metric::Counter, "tweak_id");
+  // Tracks number of times a tweak has failed to produce edits.
+  static constexpr trace::Metric TweakFailed(
+      "tweak_failed", trace::Metric::Counter, "tweak_id");
   TweakAttempt.record(1, TweakID);
   auto Action = [File = File.str(), Sel, TweakID = TweakID.str(),
                  CB = std::move(CB),
@@ -569,6 +572,8 @@ void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
         if (llvm::Error Err = reformatEdit(E, Style))
           elog("Failed to format {0}: {1}", It.first(), std::move(Err));
       }
+    } else {
+      TweakFailed.record(1, TweakID);
     }
     return CB(std::move(*Effect));
   };


        


More information about the cfe-commits mailing list