1 //===--- DiagnosticBase.inc - A test file mimicking Diagnostic.td ---------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file defines the TableGen core definitions for the diagnostics
10 // and diagnostic control.
12 //===----------------------------------------------------------------------===//
14 // See the Internals Manual, section The Diagnostics Subsystem for an overview.
16 // Define the diagnostic severities.
17 class Severity<string N> {
20 def SEV_Ignored : Severity<"Ignored">;
21 def SEV_Remark : Severity<"Remark">;
22 def SEV_Warning : Severity<"Warning">;
23 def SEV_Error : Severity<"Error">;
24 def SEV_Fatal : Severity<"Fatal">;
26 // Define the diagnostic classes.
28 def CLASS_NOTE : DiagClass;
29 def CLASS_REMARK : DiagClass;
30 def CLASS_WARNING : DiagClass;
31 def CLASS_EXTENSION : DiagClass;
32 def CLASS_ERROR : DiagClass;
34 // Responses to a diagnostic in a SFINAE context.
36 def SFINAE_SubstitutionFailure : SFINAEResponse;
37 def SFINAE_Suppress : SFINAEResponse;
38 def SFINAE_Report : SFINAEResponse;
39 def SFINAE_AccessControl : SFINAEResponse;
41 // Textual substitutions which may be performed on the text of diagnostics
42 class TextSubstitution<string Text> {
43 string Substitution = Text;
44 // TODO: These are only here to allow substitutions to be declared inline with
46 string Component = "";
47 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 include "DiagnosticDocs.inc"
69 // All diagnostics emitted by the compiler are an indirect subclass of this.
70 class Diagnostic<string summary, DiagClass DC, Severity defaultmapping> {
71 /// Component is specified by the file with a big let directive.
73 string Summary = summary;
75 SFINAEResponse SFINAE = SFINAE_Suppress;
76 bit AccessControl = 0;
77 bit WarningNoWerror = 0;
78 bit ShowInSystemHeader = 0;
79 bit ShowInSystemMacro = 1;
81 Severity DefaultSeverity = defaultmapping;
83 string CategoryName = "";
87 SFINAEResponse SFINAE = SFINAE_SubstitutionFailure;
90 SFINAEResponse SFINAE = SFINAE_Report;
93 SFINAEResponse SFINAE = SFINAE_AccessControl;
96 class ShowInSystemHeader {
97 bit ShowInSystemHeader = 1;
100 class SuppressInSystemHeader {
101 bit ShowInSystemHeader = 0;
104 class ShowInSystemMacro {
105 bit ShowInSystemMacro = 1;
108 class SuppressInSystemMacro {
109 bit ShowInSystemMacro = 0;
116 class NonDeferrable {
120 // FIXME: ExtWarn and Extension should also be SFINAEFailure by default.
121 class Error<string str> : Diagnostic<str, CLASS_ERROR, SEV_Error>, SFINAEFailure {
122 bit ShowInSystemHeader = 1;
124 // Warnings default to on (but can be default-off'd with DefaultIgnore).
125 // This is used for warnings about questionable code; warnings about
126 // accepted language extensions should use Extension or ExtWarn below instead.
127 class Warning<string str> : Diagnostic<str, CLASS_WARNING, SEV_Warning>;
128 // Remarks can be turned on with -R flags and provide commentary, e.g. on
129 // optimizer decisions.
130 class Remark<string str> : Diagnostic<str, CLASS_REMARK, SEV_Ignored>;
131 // Extensions are warnings about accepted language extensions.
132 // Extension warnings are default-off but enabled by -pedantic.
133 class Extension<string str> : Diagnostic<str, CLASS_EXTENSION, SEV_Ignored>;
134 // ExtWarns are warnings about accepted language extensions.
135 // ExtWarn warnings are default-on.
136 class ExtWarn<string str> : Diagnostic<str, CLASS_EXTENSION, SEV_Warning>;
137 // Notes can provide supplementary information on errors, warnings, and remarks.
138 class Note<string str> : Diagnostic<str, CLASS_NOTE, SEV_Fatal/*ignored*/>;
141 class DefaultIgnore { Severity DefaultSeverity = SEV_Ignored; }
142 class DefaultWarn { Severity DefaultSeverity = SEV_Warning; }
143 class DefaultError { Severity DefaultSeverity = SEV_Error; }
144 class DefaultFatal { Severity DefaultSeverity = SEV_Fatal; }
145 class DefaultWarnNoWerror {
146 bit WarningNoWerror = 1;
148 class DefaultRemark { Severity DefaultSeverity = SEV_Remark; }