Skip to content

Commit 22dc722

Browse files
njames93tstellar
authored andcommitted
[clangd] Change the url for clang-tidy check documentation
In 6e566bc, The directory structure of the documentation for clang-tidy checks was changed, however clangd wasn't updated. Now all the links generated will point to old dead pages. This updated clangd to use the new page structure. Reviewed By: sammccall, kadircet Differential Revision: https://reviews.llvm.org/D128379 (cherry picked from commit 4c106c9)
1 parent 0adb0f9 commit 22dc722

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

clang-tools-extra/clangd/Diagnostics.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -918,9 +918,19 @@ llvm::Optional<std::string> getDiagnosticDocURI(Diag::DiagSource Source,
918918
// information to be worth linking.
919919
// https://clang.llvm.org/docs/DiagnosticsReference.html
920920
break;
921-
case Diag::ClangTidy:
922-
return {("https://clang.llvm.org/extra/clang-tidy/checks/" + Name + ".html")
923-
.str()};
921+
case Diag::ClangTidy: {
922+
StringRef Module, Check;
923+
// This won't correctly get the module for clang-analyzer checks, but as we
924+
// don't link in the analyzer that shouldn't be an issue.
925+
// This would also need updating if anyone decides to create a module with a
926+
// '-' in the name.
927+
std::tie(Module, Check) = Name.split('-');
928+
if (Module.empty() || Check.empty())
929+
return llvm::None;
930+
return ("https://clang.llvm.org/extra/clang-tidy/checks/" + Module + "/" +
931+
Check + ".html")
932+
.str();
933+
}
924934
case Diag::Clangd:
925935
if (Name == "unused-includes")
926936
return {"https://clangd.llvm.org/guides/include-cleaner"};

clang-tools-extra/clangd/test/diagnostics-tidy.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# CHECK-NEXT: {
1010
# CHECK-NEXT: "code": "bugprone-sizeof-expression",
1111
# CHECK-NEXT: "codeDescription": {
12-
# CHECK-NEXT: "href": "https://clang.llvm.org/extra/clang-tidy/checks/bugprone-sizeof-expression.html"
12+
# CHECK-NEXT: "href": "https://clang.llvm.org/extra/clang-tidy/checks/bugprone/sizeof-expression.html"
1313
# CHECK-NEXT: },
1414
# CHECK-NEXT: "message": "Suspicious usage of 'sizeof(K)'; did you mean 'K'?",
1515
# CHECK-NEXT: "range": {

0 commit comments

Comments
 (0)