[clang] 744e2a3 - [analyzer] ClangSA should tablegen doc urls refering to the main doc page

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 19 03:14:54 PDT 2022


Author: Balazs Benics
Date: 2022-04-19T12:14:27+02:00
New Revision: 744e2a3e2232db87cb68b201739956ca205dc946

URL: https://github.com/llvm/llvm-project/commit/744e2a3e2232db87cb68b201739956ca205dc946
DIFF: https://github.com/llvm/llvm-project/commit/744e2a3e2232db87cb68b201739956ca205dc946.diff

LOG: [analyzer] ClangSA should tablegen doc urls refering to the main doc page

AFAIK we should prefer
https://clang.llvm.org/docs/analyzer/checkers.html to
https://clang-analyzer.llvm.org/{available_checks,alpha_checks}.html

This patch will ensure that the doc urls produced by tablegen for the
ClangSA, will use the new url. Nothing else will be changed.

Reviewed By: martong, Szelethus, ASDenysPetrov

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

Added: 
    

Modified: 
    clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
    clang/utils/TableGen/ClangSACheckersEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif b/clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
index 0f47941849500..9005a3654ad0e 100644
--- a/clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
+++ b/clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
@@ -451,7 +451,7 @@
               "fullDescription": {
                 "text": "Check for logical errors for function calls and Objective-C message expressions (e.g., uninitialized arguments, null function pointers)"
               },
-              "helpUri": "https://clang-analyzer.llvm.org/available_checks.html#core.CallAndMessage",
+              "helpUri": "https://clang.llvm.org/docs/analyzer/checkers.html#core-callandmessage",
               "id": "core.CallAndMessage",
               "name": "core.CallAndMessage"
             },
@@ -459,7 +459,7 @@
               "fullDescription": {
                 "text": "Check for division by zero"
               },
-              "helpUri": "https://clang-analyzer.llvm.org/available_checks.html#core.DivideZero",
+              "helpUri": "https://clang.llvm.org/docs/analyzer/checkers.html#core-dividezero",
               "id": "core.DivideZero",
               "name": "core.DivideZero"
             },
@@ -467,7 +467,7 @@
               "fullDescription": {
                 "text": "Check for memory leaks, double free, and use-after-free problems. Traces memory managed by malloc()/free()."
               },
-              "helpUri": "https://clang-analyzer.llvm.org/available_checks.html#unix.Malloc",
+              "helpUri": "https://clang.llvm.org/docs/analyzer/checkers.html#unix-malloc",
               "id": "unix.Malloc",
               "name": "unix.Malloc"
             }

diff  --git a/clang/utils/TableGen/ClangSACheckersEmitter.cpp b/clang/utils/TableGen/ClangSACheckersEmitter.cpp
index 61a47ee61fac4..22bec37bc1fa5 100644
--- a/clang/utils/TableGen/ClangSACheckersEmitter.cpp
+++ b/clang/utils/TableGen/ClangSACheckersEmitter.cpp
@@ -75,23 +75,18 @@ static inline uint64_t getValueFromBitsInit(const BitsInit *B, const Record &R)
 }
 
 static std::string getCheckerDocs(const Record &R) {
-  StringRef LandingPage;
   const BitsInit *BI = R.getValueAsBitsInit("Documentation");
   if (!BI)
     PrintFatalError(R.getLoc(), "missing Documentation<...> member for " +
                                     getCheckerFullName(&R));
 
-  uint64_t V = getValueFromBitsInit(BI, R);
-  if (V == 1)
-    LandingPage = "available_checks.html";
-  else if (V == 2)
-    LandingPage = "alpha_checks.html";
-
-  if (LandingPage.empty())
+  // Ignore 'Documentation<NotDocumented>' checkers.
+  if (getValueFromBitsInit(BI, R) == 0)
     return "";
 
-  return (llvm::Twine("https://clang-analyzer.llvm.org/") + LandingPage + "#" +
-          getCheckerFullName(&R))
+  std::string CheckerFullName = StringRef(getCheckerFullName(&R, "-")).lower();
+  return (llvm::Twine("https://clang.llvm.org/docs/analyzer/checkers.html#") +
+          CheckerFullName)
       .str();
 }
 


        


More information about the cfe-commits mailing list