[PATCH] D63926: [clangd] Make FixIt message be consistent with the clang-tidy diagnostic message.

Haojian Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 1 01:05:48 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL364731: [clangd] Make FixIt message be consistent with the clang-tidy diagnostic… (authored by hokein, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63926?vs=207038&id=207238#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63926/new/

https://reviews.llvm.org/D63926

Files:
  clang-tools-extra/trunk/clangd/Diagnostics.cpp
  clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/trunk/clangd/Diagnostics.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/Diagnostics.cpp
+++ clang-tools-extra/trunk/clangd/Diagnostics.cpp
@@ -418,6 +418,8 @@
         CleanMessage(Diag.Message);
         for (auto &Note : Diag.Notes)
           CleanMessage(Note.Message);
+        for (auto &Fix : Diag.Fixes)
+          CleanMessage(Fix.Message);
         continue;
       }
     }
Index: clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp
@@ -60,6 +60,10 @@
          arg.Edits[0].range == Range && arg.Edits[0].newText == Replacement;
 }
 
+MATCHER_P(FixMessage, Message, "") {
+  return arg.Message == Message;
+}
+
 MATCHER_P(EqualToLSPDiag, LSPDiag,
           "LSP diagnostic " + llvm::to_string(LSPDiag)) {
   if (toJSON(arg) != toJSON(LSPDiag)) {
@@ -180,19 +184,17 @@
     #include $deprecated[["assert.h"]]
 
     #define $macrodef[[SQUARE]](X) (X)*(X)
-    int main() {
-      return $doubled[[sizeof]](sizeof(int));
-    }
-    int square() {
+    int $main[[main]]() {
       int y = 4;
       return SQUARE($macroarg[[++]]y);
+      return $doubled[[sizeof]](sizeof(int));
     }
   )cpp");
   auto TU = TestTU::withCode(Test.code());
   TU.HeaderFilename = "assert.h"; // Suppress "not found" error.
   TU.ClangTidyChecks =
       "-*, bugprone-sizeof-expression, bugprone-macro-repeated-side-effects, "
-      "modernize-deprecated-headers";
+      "modernize-deprecated-headers, modernize-use-trailing-return-type";
   EXPECT_THAT(
       TU.build().getDiagnostics(),
       UnorderedElementsAre(
@@ -214,7 +216,15 @@
               WithNote(
                   Diag(Test.range("macrodef"), "macro 'SQUARE' defined here"))),
           Diag(Test.range("macroarg"),
-               "multiple unsequenced modifications to 'y'")));
+               "multiple unsequenced modifications to 'y'"),
+          AllOf(
+            Diag(Test.range("main"),
+                 "use a trailing return type for this function"),
+            DiagSource(Diag::ClangTidy),
+            DiagName("modernize-use-trailing-return-type"),
+            // Verify that we don't have "[check-name]" suffix in the message.
+            WithFix(FixMessage("use a trailing return type for this function")))
+          ));
 }
 
 TEST(DiagnosticTest, ClangTidySuppressionComment) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63926.207238.patch
Type: text/x-patch
Size: 2568 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190701/2605af63/attachment.bin>


More information about the llvm-commits mailing list