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 // Diagnostic Categories. These can be applied to groups or individual
43 // diagnostics to specify a category.
44 class DiagCategory<string Name> {
45 string CategoryName = Name;
49 class DiagGroup<string Name, list<DiagGroup> subgroups = []> {
50 string GroupName = Name;
51 list<DiagGroup> SubGroups = subgroups;
52 string CategoryName = "";
53 code Documentation = [{}];
55 class InGroup<DiagGroup G> { DiagGroup Group = G; }
56 //class IsGroup<string Name> { DiagGroup Group = DiagGroup<Name>; }
58 // This defines documentation for diagnostic groups.
59 include "DiagnosticDocs.td"
61 // This defines all of the named diagnostic categories.
62 include "DiagnosticCategories.td"
64 // This defines all of the named diagnostic groups.
65 include "DiagnosticGroups.td"
68 // All diagnostics emitted by the compiler are an indirect subclass of this.
69 class Diagnostic<string text, DiagClass DC, Severity defaultmapping> {
70 /// Component is specified by the file with a big let directive.
74 SFINAEResponse SFINAE = SFINAE_Suppress;
75 bit AccessControl = 0;
76 bit WarningNoWerror = 0;
77 bit ShowInSystemHeader = 0;
78 Severity DefaultSeverity = defaultmapping;
80 string CategoryName = "";
84 SFINAEResponse SFINAE = SFINAE_SubstitutionFailure;
87 SFINAEResponse SFINAE = SFINAE_Report;
90 SFINAEResponse SFINAE = SFINAE_AccessControl;
93 class ShowInSystemHeader {
94 bit ShowInSystemHeader = 1;
97 class SuppressInSystemHeader {
98 bit ShowInSystemHeader = 0;
101 // FIXME: ExtWarn and Extension should also be SFINAEFailure by default.
102 class Error<string str> : Diagnostic<str, CLASS_ERROR, SEV_Error>, SFINAEFailure {
103 bit ShowInSystemHeader = 1;
105 // Warnings default to on (but can be default-off'd with DefaultIgnore).
106 // This is used for warnings about questionable code; warnings about
107 // accepted language extensions should use Extension or ExtWarn below instead.
108 class Warning<string str> : Diagnostic<str, CLASS_WARNING, SEV_Warning>;
109 // Remarks can be turned on with -R flags and provide commentary, e.g. on
110 // optimizer decisions.
111 class Remark<string str> : Diagnostic<str, CLASS_REMARK, SEV_Ignored>;
112 // Extensions are warnings about accepted language extensions.
113 // Extension warnings are default-off but enabled by -pedantic.
114 class Extension<string str> : Diagnostic<str, CLASS_EXTENSION, SEV_Ignored>;
115 // ExtWarns are warnings about accepted language extensions.
116 // ExtWarn warnings are default-on.
117 class ExtWarn<string str> : Diagnostic<str, CLASS_EXTENSION, SEV_Warning>;
118 // Notes can provide supplementary information on errors, warnings, and remarks.
119 class Note<string str> : Diagnostic<str, CLASS_NOTE, SEV_Fatal/*ignored*/>;
122 class DefaultIgnore { Severity DefaultSeverity = SEV_Ignored; }
123 class DefaultWarn { Severity DefaultSeverity = SEV_Warning; }
124 class DefaultError { Severity DefaultSeverity = SEV_Error; }
125 class DefaultFatal { Severity DefaultSeverity = SEV_Fatal; }
126 class DefaultWarnNoWerror {
127 bit WarningNoWerror = 1;
129 class DefaultRemark { Severity DefaultSeverity = SEV_Remark; }
131 // Definitions for Diagnostics.
132 include "DiagnosticASTKinds.td"
133 include "DiagnosticAnalysisKinds.td"
134 include "DiagnosticCommentKinds.td"
135 include "DiagnosticCommonKinds.td"
136 include "DiagnosticCrossTUKinds.td"
137 include "DiagnosticDriverKinds.td"
138 include "DiagnosticFrontendKinds.td"
139 include "DiagnosticLexKinds.td"
140 include "DiagnosticParseKinds.td"
141 include "DiagnosticRefactoringKinds.td"
142 include "DiagnosticSemaKinds.td"
143 include "DiagnosticSerializationKinds.td"