Clang Project

clang_source_code/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
1//===--- CheckerBase.td - Checker TableGen classes ------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9//  This file defines the TableGen core definitions for checkers
10//
11//===----------------------------------------------------------------------===//
12
13/// Describes a package. Every checker is a part of a package, for example,
14/// 'NullDereference' is part of the 'core' package, hence it's full name is
15/// 'core.NullDereference'.
16/// Example:
17///   def Core : Package<"core">;
18class Package<string name> {
19  string       PackageName = name;
20  Package ParentPackage;
21}
22
23/// Describes a 'super' package that holds another package inside it. This is
24/// used to nest packages in one another. One may, for example, create the
25/// 'builtin' package inside 'core', thus creating the package 'core.builtin'.
26/// Example:
27///   def CoreBuiltin : Package<"builtin">, ParentPackage<Core>;
28class ParentPackage<Package P> { Package ParentPackage = P; }
29
30/// A description. May be displayed to the user when clang is invoked with
31/// a '-help'-like command line option.
32class HelpText<string text> { string HelpText = text; }
33
34/// Describes what kind of documentation exists for the checker.
35class DocumentationEnum<bits<2> val> {
36  bits<2> Documentation = val;
37}
38def NotDocumented : DocumentationEnum<0>;
39def HasDocumentation : DocumentationEnum<1>;
40def HasAlphaDocumentation : DocumentationEnum<2>;
41
42class Documentation<DocumentationEnum val> {
43  bits<2> Documentation = val.Documentation;
44}
45
46/// Describes a checker. Every builtin checker has to be registered with the use
47/// of this class (out-of-trunk checkers loaded from plugins obviously don't).
48/// Note that a checker has a name (e.g.: 'NullDereference'), and a fullname,
49/// that is autogenerated with the help of the ParentPackage field, that also
50/// includes package names (e.g.: 'core.NullDereference').
51/// Example:
52///   def DereferenceChecker : Checker<"NullDereference">,
53///     HelpText<"Check for dereferences of null pointers">;
54class Checker<string name = ""> {
55  string        CheckerName = name;
56  string        HelpText;
57  list<Checker> Dependencies;
58  bits<2>       Documentation;
59  Package       ParentPackage;
60}
61
62/// Describes dependencies in between checkers. For example, InnerPointerChecker
63/// relies on information MallocBase gathers.
64/// Example:
65///   def InnerPointerChecker : Checker<"InnerPointer">,
66///     HelpText<"Check for inner pointers of C++ containers used after "
67///              "re/deallocation">,
68///     Dependencies<[MallocBase]>;
69class Dependencies<list<Checker> Deps = []> {
70  list<Checker> Dependencies = Deps;
71}
72