Diagnostic.td 5.6 KB

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