]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / 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 checker or package option type. This is important for validating
14 /// user supplied inputs.
15 /// New option types can be added by modifying this enum. Note that this
16 /// requires changes in the TableGen emitter file ClangSACheckersEmitter.cpp.
17 class CmdLineOptionTypeEnum<bits<2> val> {
18   bits<2> Type = val;
19 }
20 def Integer : CmdLineOptionTypeEnum<0>;
21 def String : CmdLineOptionTypeEnum<1>;
22 def Boolean : CmdLineOptionTypeEnum<2>;
23
24 /// Describes the state of the entry. We wouldn't like to display, for example,
25 /// developer only entries for a list meant for end users.
26 class DevelopmentStageEnum<bits<1> val> {
27   bits<1> Val = val;
28 }
29
30 /// Alpha entries are under development, might be incomplet, inkorrekt and
31 /// unstable.
32 def InAlpha : DevelopmentStageEnum<0>;
33
34 /// Released entries are stable, produce minimal, if any false positives,
35 /// and emits reports that explain the occurance of the bug understandably and
36 /// thoroughly.
37 def Released : DevelopmentStageEnum<1>;
38
39 /// Marks the entry hidden. Hidden entries won't be displayed in
40 /// -analyzer-checker-option-help.
41 class HiddenEnum<bit val> {
42   bit Val = val;
43 }
44 def DontHide : HiddenEnum<0>;
45 def Hide : HiddenEnum<1>;
46
47 /// Describes an option for a checker or a package.
48 class CmdLineOption<CmdLineOptionTypeEnum type, string cmdFlag, string desc,
49                     string defaultVal, DevelopmentStageEnum stage,
50                     HiddenEnum isHidden = DontHide> {
51   bits<2> Type = type.Type;
52   string  CmdFlag = cmdFlag;
53   string  Desc = desc;
54   string  DefaultVal = defaultVal;
55   bits<1> DevelopmentStage = stage.Val;
56   bit     Hidden = isHidden.Val;
57 }
58
59 /// Describes a list of package options.
60 class PackageOptions<list<CmdLineOption> opts> {
61   list<CmdLineOption> PackageOptions = opts;
62 }
63
64 /// Describes a package. Every checker is a part of a package, for example,
65 /// 'NullDereference' is part of the 'core' package, hence it's full name is
66 /// 'core.NullDereference'.
67 /// Example:
68 ///   def Core : Package<"core">;
69 class Package<string name> {
70   string              PackageName = name;
71   // This field is optional.
72   list<CmdLineOption> PackageOptions;
73   Package             ParentPackage;
74   bit                 Hidden = 0;
75 }
76
77 /// Describes a 'super' package that holds another package inside it. This is
78 /// used to nest packages in one another. One may, for example, create the
79 /// 'builtin' package inside 'core', thus creating the package 'core.builtin'.
80 /// Example:
81 ///   def CoreBuiltin : Package<"builtin">, ParentPackage<Core>;
82 class ParentPackage<Package P> { Package ParentPackage = P; }
83
84 /// A description. May be displayed to the user when clang is invoked with
85 /// a '-help'-like command line option.
86 class HelpText<string text> { string HelpText = text; }
87
88 /// Describes what kind of documentation exists for the checker.
89 class DocumentationEnum<bits<2> val> {
90   bits<2> Documentation = val;
91 }
92 def NotDocumented : DocumentationEnum<0>;
93 def HasDocumentation : DocumentationEnum<1>;
94 def HasAlphaDocumentation : DocumentationEnum<2>;
95
96 class Documentation<DocumentationEnum val> {
97   bits<2> Documentation = val.Documentation;
98 }
99
100 /// Describes a checker. Every builtin checker has to be registered with the use
101 /// of this class (out-of-trunk checkers loaded from plugins obviously don't).
102 /// Note that a checker has a name (e.g.: 'NullDereference'), and a fullname,
103 /// that is autogenerated with the help of the ParentPackage field, that also
104 /// includes package names (e.g.: 'core.NullDereference').
105 /// Example:
106 ///   def DereferenceChecker : Checker<"NullDereference">,
107 ///     HelpText<"Check for dereferences of null pointers">;
108 class Checker<string name = ""> {
109   string              CheckerName = name;
110   string              HelpText;
111   // This field is optional.
112   list<CmdLineOption> CheckerOptions;
113   // This field is optional.
114   list<Checker>       Dependencies;
115   bits<2>             Documentation;
116   Package             ParentPackage;
117   bit                 Hidden = 0;
118 }
119
120 /// Describes a list of checker options.
121 class CheckerOptions<list<CmdLineOption> opts> {
122   list<CmdLineOption> CheckerOptions = opts;
123 }
124
125 /// Describes dependencies in between checkers. For example, InnerPointerChecker
126 /// relies on information MallocBase gathers.
127 /// Example:
128 ///   def InnerPointerChecker : Checker<"InnerPointer">,
129 ///     HelpText<"Check for inner pointers of C++ containers used after "
130 ///              "re/deallocation">,
131 ///     Dependencies<[MallocBase]>;
132 class Dependencies<list<Checker> Deps = []> {
133   list<Checker> Dependencies = Deps;
134 }
135
136 /// Marks a checker or a package hidden. Hidden entries are meant for developers
137 /// only, and aren't exposed to end users.
138 class Hidden { bit Hidden = 1; }