Clang Project

clang_source_code/test/TableGen/DiagnosticBase.inc
1//===--- DiagnosticBase.inc - A test file mimicking Diagnostic.td ---------===//
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 the diagnostics
10//  and diagnostic control.
11//
12//===----------------------------------------------------------------------===//
13
14// See the Internals Manual, section The Diagnostics Subsystem for an overview.
15
16// Define the diagnostic severities.
17class Severity<string N> {
18  string Name = N;
19}
20def SEV_Ignored : Severity<"Ignored">;
21def SEV_Remark  : Severity<"Remark">;
22def SEV_Warning : Severity<"Warning">;
23def SEV_Error   : Severity<"Error">;
24def SEV_Fatal   : Severity<"Fatal">;
25
26// Define the diagnostic classes.
27class DiagClass;
28def CLASS_NOTE      : DiagClass;
29def CLASS_REMARK    : DiagClass;
30def CLASS_WARNING   : DiagClass;
31def CLASS_EXTENSION : DiagClass;
32def CLASS_ERROR     : DiagClass;
33
34// Responses to a diagnostic in a SFINAE context.
35class SFINAEResponse;
36def SFINAE_SubstitutionFailure : SFINAEResponse;
37def SFINAE_Suppress            : SFINAEResponse;
38def SFINAE_Report              : SFINAEResponse;
39def SFINAE_AccessControl       : SFINAEResponse;
40
41// Textual substitutions which may be performed on the text of diagnostics
42class TextSubstitution<string Text> {
43  string Substitution = Text;
44  // TODO: These are only here to allow substitutions to be declared inline with
45  // diagnostics
46  string Component = "";
47  string CategoryName = "";
48}
49
50// Diagnostic Categories.  These can be applied to groups or individual
51// diagnostics to specify a category.
52class DiagCategory<string Name> {
53  string CategoryName = Name;
54}
55
56// Diagnostic Groups.
57class DiagGroup<string Name, list<DiagGroup> subgroups = []> {
58  string GroupName = Name;
59  list<DiagGroup> SubGroups = subgroups;
60  string CategoryName = "";
61  code Documentation = [{}];
62}
63class InGroup<DiagGroup G> { DiagGroup Group = G; }
64//class IsGroup<string Name> { DiagGroup Group = DiagGroup<Name>; }
65
66include "DiagnosticDocs.inc"
67
68// All diagnostics emitted by the compiler are an indirect subclass of this.
69class Diagnostic<string text, DiagClass DC, Severity defaultmapping> {
70  /// Component is specified by the file with a big let directive.
71  string         Component = ?;
72  string         Text = text;
73  DiagClass      Class = DC;
74  SFINAEResponse SFINAE = SFINAE_Suppress;
75  bit            AccessControl = 0;
76  bit            WarningNoWerror = 0;
77  bit            ShowInSystemHeader = 0;
78  Severity       DefaultSeverity = defaultmapping;
79  DiagGroup      Group;
80  string         CategoryName = "";
81}
82
83class SFINAEFailure {
84  SFINAEResponse SFINAE = SFINAE_SubstitutionFailure;
85}
86class NoSFINAE {
87  SFINAEResponse SFINAE = SFINAE_Report;
88}
89class AccessControl {
90  SFINAEResponse SFINAE = SFINAE_AccessControl;
91}
92
93class ShowInSystemHeader {
94  bit ShowInSystemHeader = 1;
95}
96
97class SuppressInSystemHeader {
98  bit ShowInSystemHeader = 0;
99}
100
101// FIXME: ExtWarn and Extension should also be SFINAEFailure by default.
102class Error<string str>     : Diagnostic<str, CLASS_ERROR, SEV_Error>, SFINAEFailure {
103  bit ShowInSystemHeader = 1;
104}
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.
108class 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.
111class 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.
114class Extension<string str> : Diagnostic<str, CLASS_EXTENSION, SEV_Ignored>;
115// ExtWarns are warnings about accepted language extensions.
116// ExtWarn warnings are default-on.
117class ExtWarn<string str>   : Diagnostic<str, CLASS_EXTENSION, SEV_Warning>;
118// Notes can provide supplementary information on errors, warnings, and remarks.
119class Note<string str>      : Diagnostic<str, CLASS_NOTE, SEV_Fatal/*ignored*/>;
120
121
122class DefaultIgnore { Severity DefaultSeverity = SEV_Ignored; }
123class DefaultWarn   { Severity DefaultSeverity = SEV_Warning; }
124class DefaultError  { Severity DefaultSeverity = SEV_Error; }
125class DefaultFatal  { Severity DefaultSeverity = SEV_Fatal; }
126class DefaultWarnNoWerror {
127  bit WarningNoWerror = 1;
128}
129class DefaultRemark { Severity DefaultSeverity = SEV_Remark; }
130