Skip to content

Commit

Permalink
Allow direct navigation to static analysis checker documentation thro…
Browse files Browse the repository at this point in the history
…ugh SARIF exports.

This adds anchors to all of the documented checks so that you can directly link to a check by a stable name. This is useful because the SARIF file format has a field for specifying a URI to documentation for a rule and some viewers, like CodeSonar, make use of this information. These links are then exposed through the SARIF exporter.

llvm-svn: 349812
  • Loading branch information
AaronBallman committed Dec 20, 2018
1 parent ed41484 commit 2f234cb
Show file tree
Hide file tree
Showing 12 changed files with 635 additions and 421 deletions.
2 changes: 1 addition & 1 deletion clang/include/clang/Driver/CC1Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def analyzer_checker : Separate<["-"], "analyzer-checker">,
ValuesCode<[{
const char *Values =
#define GET_CHECKERS
#define CHECKER(FULLNAME, CLASS, HT) FULLNAME ","
#define CHECKER(FULLNAME, CLASS, HT, DOC_URI) FULLNAME ","
#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
#undef GET_CHECKERS
#define GET_PACKAGES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CheckerManager;
class CheckerRegistry;

#define GET_CHECKERS
#define CHECKER(FULLNAME, CLASS, HELPTEXT) \
#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI) \
void register##CLASS(CheckerManager &mgr);
#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
#undef CHECKER
Expand Down
13 changes: 13 additions & 0 deletions clang/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ class ParentPackage<Package P> { Package ParentPackage = P; }
/// a '-help'-like command line option.
class HelpText<string text> { string HelpText = text; }

/// Describes what kind of documentation exists for the checker.
class DocumentationEnum<bits<2> val> {
bits<2> Documentation = val;
}
def NotDocumented : DocumentationEnum<0>;
def HasDocumentation : DocumentationEnum<1>;
def HasAlphaDocumentation : DocumentationEnum<2>;

class Documentation<DocumentationEnum val> {
bits<2> Documentation = val.Documentation;
}

/// Describes a checker. Every builtin checker has to be registered with the use
/// of this class (out-of-trunk checkers loaded from plugins obviously don't).
/// Note that a checker has a name (e.g.: 'NullDereference'), and a fullname,
Expand All @@ -40,5 +52,6 @@ class HelpText<string text> { string HelpText = text; }
class Checker<string name = ""> {
string CheckerName = name;
string HelpText;
bits<2> Documentation;
Package ParentPackage;
}
Loading

0 comments on commit 2f234cb

Please sign in to comment.