1//===--- Diagnostic.td - C Language Family Diagnostic Handling ------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10//  This file defines the TableGen core definitions for the diagnostics
11//  and diagnostic control.
12//
13//===----------------------------------------------------------------------===//
14
15// See the Internals Manual, section The Diagnostics Subsystem for an overview.
16
17// Define the diagnostic severities.
18class Severity<string N> {
19  string Name = N;
20}
21def SEV_Ignored : Severity<"Ignored">;
22def SEV_Remark  : Severity<"Remark">;
23def SEV_Warning : Severity<"Warning">;
24def SEV_Error   : Severity<"Error">;
25def SEV_Fatal   : Severity<"Fatal">;
26
27// Define the diagnostic classes.
28class DiagClass;
29def CLASS_NOTE      : DiagClass;
30def CLASS_REMARK    : DiagClass;
31def CLASS_WARNING   : DiagClass;
32def CLASS_EXTENSION : DiagClass;
33def CLASS_ERROR     : DiagClass;
34
35// Responses to a diagnostic in a SFINAE context.
36class SFINAEResponse;
37def SFINAE_SubstitutionFailure : SFINAEResponse;
38def SFINAE_Suppress            : SFINAEResponse;
39def SFINAE_Report              : SFINAEResponse;
40def SFINAE_AccessControl       : SFINAEResponse;
41
42// Textual substitutions which may be performed on the text of diagnostics
43class TextSubstitution<string Text> {
44  string Substitution = Text;
45  // TODO: These are only here to allow substitutions to be declared inline with
46  // diagnostics
47  string Component = "";
48  string CategoryName = "";
49}
50
51// Diagnostic Categories.  These can be applied to groups or individual
52// diagnostics to specify a category.
53class DiagCategory<string Name> {
54  string CategoryName = Name;
55}
56
57// Diagnostic Groups.
58class DiagGroup<string Name, list<DiagGroup> subgroups = []> {
59  string GroupName = Name;
60  list<DiagGroup> SubGroups = subgroups;
61  string CategoryName = "";
62  code Documentation = [{}];
63}
64class InGroup<DiagGroup G> { DiagGroup Group = G; }
65//class IsGroup<string Name> { DiagGroup Group = DiagGroup<Name>; }
66
67// This defines documentation for diagnostic groups.
68include "DiagnosticDocs.td"
69
70// This defines all of the named diagnostic categories.
71include "DiagnosticCategories.td"
72
73// This defines all of the named diagnostic groups.
74include "DiagnosticGroups.td"
75
76
77// All diagnostics emitted by the compiler are an indirect subclass of this.
78class Diagnostic<string text, DiagClass DC, Severity defaultmapping> {
79  /// Component is specified by the file with a big let directive.
80  string         Component = ?;
81  string         Text = text;
82  DiagClass      Class = DC;
83  SFINAEResponse SFINAE = SFINAE_Suppress;
84  bit            AccessControl = 0;
85  bit            WarningNoWerror = 0;
86  bit            ShowInSystemHeader = 0;
87  Severity       DefaultSeverity = defaultmapping;
88  DiagGroup      Group;
89  string         CategoryName = "";
90}
91
92class SFINAEFailure {
93  SFINAEResponse SFINAE = SFINAE_SubstitutionFailure;
94}
95class NoSFINAE {
96  SFINAEResponse SFINAE = SFINAE_Report;
97}
98class AccessControl {
99  SFINAEResponse SFINAE = SFINAE_AccessControl;
100}
101
102class ShowInSystemHeader {
103  bit ShowInSystemHeader = 1;
104}
105
106class SuppressInSystemHeader {
107  bit ShowInSystemHeader = 0;
108}
109
110// FIXME: ExtWarn and Extension should also be SFINAEFailure by default.
111class Error<string str>     : Diagnostic<str, CLASS_ERROR, SEV_Error>, SFINAEFailure {
112  bit ShowInSystemHeader = 1;
113}
114// Warnings default to on (but can be default-off'd with DefaultIgnore).
115// This is used for warnings about questionable code; warnings about
116// accepted language extensions should use Extension or ExtWarn below instead.
117class Warning<string str>   : Diagnostic<str, CLASS_WARNING, SEV_Warning>;
118// Remarks can be turned on with -R flags and provide commentary, e.g. on
119// optimizer decisions.
120class Remark<string str>    : Diagnostic<str, CLASS_REMARK, SEV_Ignored>;
121// Extensions are warnings about accepted language extensions.
122// Extension warnings are default-off but enabled by -pedantic.
123class Extension<string str> : Diagnostic<str, CLASS_EXTENSION, SEV_Ignored>;
124// ExtWarns are warnings about accepted language extensions.
125// ExtWarn warnings are default-on.
126class ExtWarn<string str>   : Diagnostic<str, CLASS_EXTENSION, SEV_Warning>;
127// Notes can provide supplementary information on errors, warnings, and remarks.
128class Note<string str>      : Diagnostic<str, CLASS_NOTE, SEV_Fatal/*ignored*/>;
129
130
131class DefaultIgnore { Severity DefaultSeverity = SEV_Ignored; }
132class DefaultWarn   { Severity DefaultSeverity = SEV_Warning; }
133class DefaultError  { Severity DefaultSeverity = SEV_Error; }
134class DefaultFatal  { Severity DefaultSeverity = SEV_Fatal; }
135class DefaultWarnNoWerror {
136  bit WarningNoWerror = 1;
137}
138class DefaultRemark { Severity DefaultSeverity = SEV_Remark; }
139
140// Definitions for Diagnostics.
141include "DiagnosticASTKinds.td"
142include "DiagnosticAnalysisKinds.td"
143include "DiagnosticCommentKinds.td"
144include "DiagnosticCommonKinds.td"
145include "DiagnosticCrossTUKinds.td"
146include "DiagnosticDriverKinds.td"
147include "DiagnosticFrontendKinds.td"
148include "DiagnosticLexKinds.td"
149include "DiagnosticParseKinds.td"
150include "DiagnosticRefactoringKinds.td"
151include "DiagnosticSemaKinds.td"
152include "DiagnosticSerializationKinds.td"
153
154