[clang-tools-extra] r364731 - [clangd] Make FixIt message be consistent with the clang-tidy diagnostic message.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 1 01:05:53 PDT 2019
Author: hokein
Date: Mon Jul 1 01:05:53 2019
New Revision: 364731
URL: http://llvm.org/viewvc/llvm-project?rev=364731&view=rev
Log:
[clangd] Make FixIt message be consistent with the clang-tidy diagnostic message.
Summary:
We strip the "[clang-tidy-check]" suffix from the clang-tidy diagnostics, we
should be consistent with the message in FixIt (strip the suffix as well).
Reviewers: sammccall
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D63926
Modified:
clang-tools-extra/trunk/clangd/Diagnostics.cpp
clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp
Modified: clang-tools-extra/trunk/clangd/Diagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Diagnostics.cpp?rev=364731&r1=364730&r2=364731&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/Diagnostics.cpp (original)
+++ clang-tools-extra/trunk/clangd/Diagnostics.cpp Mon Jul 1 01:05:53 2019
@@ -418,6 +418,8 @@ std::vector<Diag> StoreDiags::take(const
CleanMessage(Diag.Message);
for (auto &Note : Diag.Notes)
CleanMessage(Note.Message);
+ for (auto &Fix : Diag.Fixes)
+ CleanMessage(Fix.Message);
continue;
}
}
Modified: clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp?rev=364731&r1=364730&r2=364731&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp Mon Jul 1 01:05:53 2019
@@ -60,6 +60,10 @@ MATCHER_P3(Fix, Range, Replacement, Mess
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 @@ TEST(DiagnosticsTest, ClangTidy) {
#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 @@ TEST(DiagnosticsTest, ClangTidy) {
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) {
More information about the cfe-commits
mailing list