1 //===--- Diagnostic.td - C Language Family Diagnostic Handling ------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the TableGen core definitions for the diagnostics
11 // and diagnostic control.
13 //===----------------------------------------------------------------------===//
15 // See the Internals Manual, section The Diagnostics Subsystem for an overview.
17 // Define the diagnostic severities.
18 class Severity<string N> {
21 def SEV_Ignored : Severity<"Ignored">;
22 def SEV_Remark : Severity<"Remark">;
23 def SEV_Warning : Severity<"Warning">;
24 def SEV_Error : Severity<"Error">;
25 def SEV_Fatal : Severity<"Fatal">;
27 // Define the diagnostic classes.
29 def CLASS_NOTE : DiagClass;
30 def CLASS_REMARK : DiagClass;
31 def CLASS_WARNING : DiagClass;
32 def CLASS_EXTENSION : DiagClass;
33 def CLASS_ERROR : DiagClass;
35 // Responses to a diagnostic in a SFINAE context.
37 def SFINAE_SubstitutionFailure : SFINAEResponse;
38 def SFINAE_Suppress : SFINAEResponse;
39 def SFINAE_Report : SFINAEResponse;
40 def SFINAE_AccessControl : SFINAEResponse;
42 // Textual substitutions which may be performed on the text of diagnostics
43 class TextSubstitution<string Text> {
44 string Substitution = Text;
45 // TODO: These are only here to allow substitutions to be declared inline with
47 string Component = "";
48 string CategoryName = "";
51 // Diagnostic Categories. These can be applied to groups or individual
52 // diagnostics to specify a category.
53 class DiagCategory<string Name> {
54 string CategoryName = Name;
58 class DiagGroup<string Name, list<DiagGroup> subgroups = []> {
59 string GroupName = Name;
60 list<DiagGroup> SubGroups = subgroups;
61 string CategoryName = "";
62 code Documentation = [{}];
64 class InGroup<DiagGroup G> { DiagGroup Group = G; }
65 //class IsGroup<string Name> { DiagGroup Group = DiagGroup<Name>; }
67 // This defines documentation for diagnostic groups.
68 include "DiagnosticDocs.td"
70 // This defines all of the named diagnostic categories.
71 include "DiagnosticCategories.td"
73 // This defines all of the named diagnostic groups.
74 include "DiagnosticGroups.td"
77 // All diagnostics emitted by the compiler are an indirect subclass of this.
78 class Diagnostic<string text, DiagClass DC, Severity defaultmapping> {
79 /// Component is specified by the file with a big let directive.
83 SFINAEResponse SFINAE = SFINAE_Suppress;
84 bit AccessControl = 0;
85 bit WarningNoWerror = 0;
86 bit ShowInSystemHeader = 0;
87 Severity DefaultSeverity = defaultmapping;
89 string CategoryName = "";
93 SFINAEResponse SFINAE = SFINAE_SubstitutionFailure;
96 SFINAEResponse SFINAE = SFINAE_Report;
99 SFINAEResponse SFINAE = SFINAE_AccessControl;
102 class ShowInSystemHeader {
103 bit ShowInSystemHeader = 1;
106 class SuppressInSystemHeader {
107 bit ShowInSystemHeader = 0;
110 // FIXME: ExtWarn and Extension should also be SFINAEFailure by default.
111 class Error<string str> : Diagnostic<str, CLASS_ERROR, SEV_Error>, SFINAEFailure {
112 bit ShowInSystemHeader = 1;
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.
117 class 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.
120 class 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.
123 class Extension<string str> : Diagnostic<str, CLASS_EXTENSION, SEV_Ignored>;
124 // ExtWarns are warnings about accepted language extensions.
125 // ExtWarn warnings are default-on.
126 class ExtWarn<string str> : Diagnostic<str, CLASS_EXTENSION, SEV_Warning>;
127 // Notes can provide supplementary information on errors, warnings, and remarks.
128 class Note<string str> : Diagnostic<str, CLASS_NOTE, SEV_Fatal/*ignored*/>;
131 class DefaultIgnore { Severity DefaultSeverity = SEV_Ignored; }
132 class DefaultWarn { Severity DefaultSeverity = SEV_Warning; }
133 class DefaultError { Severity DefaultSeverity = SEV_Error; }
134 class DefaultFatal { Severity DefaultSeverity = SEV_Fatal; }
135 class DefaultWarnNoWerror {
136 bit WarningNoWerror = 1;
138 class DefaultRemark { Severity DefaultSeverity = SEV_Remark; }
140 // Definitions for Diagnostics.
141 include "DiagnosticASTKinds.td"
142 include "DiagnosticAnalysisKinds.td"
143 include "DiagnosticCommentKinds.td"
144 include "DiagnosticCommonKinds.td"
145 include "DiagnosticCrossTUKinds.td"
146 include "DiagnosticDriverKinds.td"
147 include "DiagnosticFrontendKinds.td"
148 include "DiagnosticLexKinds.td"
149 include "DiagnosticParseKinds.td"
150 include "DiagnosticRefactoringKinds.td"
151 include "DiagnosticSemaKinds.td"
152 include "DiagnosticSerializationKinds.td"