Home | History | Annotate | Download | only in Basic
      1 //===--- Diagnostic.td - C Language Family Diagnostic Handling ------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 //  This file defines the TableGen core definitions for the diagnostics
     11 //  and diagnostic control.
     12 //
     13 //===----------------------------------------------------------------------===//
     14 
     15 // Define the diagnostic severities.
     16 class Severity<string N> {
     17   string Name = N;
     18 }
     19 def SEV_Ignored : Severity<"Ignored">;
     20 def SEV_Remark  : Severity<"Remark">;
     21 def SEV_Warning : Severity<"Warning">;
     22 def SEV_Error   : Severity<"Error">;
     23 def SEV_Fatal   : Severity<"Fatal">;
     24 
     25 // Define the diagnostic classes.
     26 class DiagClass;
     27 def CLASS_NOTE      : DiagClass;
     28 def CLASS_REMARK    : DiagClass;
     29 def CLASS_WARNING   : DiagClass;
     30 def CLASS_EXTENSION : DiagClass;
     31 def CLASS_ERROR     : DiagClass;
     32 
     33 // Responses to a diagnostic in a SFINAE context.
     34 class SFINAEResponse;
     35 def SFINAE_SubstitutionFailure : SFINAEResponse;
     36 def SFINAE_Suppress            : SFINAEResponse;
     37 def SFINAE_Report              : SFINAEResponse;
     38 def SFINAE_AccessControl       : SFINAEResponse;
     39 
     40 // Diagnostic Categories.  These can be applied to groups or individual
     41 // diagnostics to specify a category.
     42 class DiagCategory<string Name> {
     43   string CategoryName = Name;
     44 }
     45 
     46 // Diagnostic Groups.
     47 class DiagGroup<string Name, list<DiagGroup> subgroups = []> {
     48   string GroupName = Name;
     49   list<DiagGroup> SubGroups = subgroups;
     50   string CategoryName = "";
     51   code Documentation = [{}];
     52 }
     53 class InGroup<DiagGroup G> { DiagGroup Group = G; }
     54 //class IsGroup<string Name> { DiagGroup Group = DiagGroup<Name>; }
     55 
     56 // This defines documentation for diagnostic groups.
     57 include "DiagnosticDocs.td"
     58 
     59 // This defines all of the named diagnostic categories.
     60 include "DiagnosticCategories.td"
     61 
     62 // This defines all of the named diagnostic groups.
     63 include "DiagnosticGroups.td"
     64 
     65 
     66 // All diagnostics emitted by the compiler are an indirect subclass of this.
     67 class Diagnostic<string text, DiagClass DC, Severity defaultmapping> {
     68   /// Component is specified by the file with a big let directive.
     69   string         Component = ?;
     70   string         Text = text;
     71   DiagClass      Class = DC;
     72   SFINAEResponse SFINAE = SFINAE_Suppress;
     73   bit            AccessControl = 0;
     74   bit            WarningNoWerror = 0;
     75   bit            ShowInSystemHeader = 0;
     76   Severity       DefaultSeverity = defaultmapping;
     77   DiagGroup      Group;
     78   string         CategoryName = "";
     79 }
     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 
     91 class ShowInSystemHeader {
     92   bit ShowInSystemHeader = 1;
     93 }
     94 
     95 class SuppressInSystemHeader {
     96   bit ShowInSystemHeader = 0;
     97 }
     98 
     99 // FIXME: ExtWarn and Extension should also be SFINAEFailure by default.
    100 class Error<string str>     : Diagnostic<str, CLASS_ERROR, SEV_Error>, SFINAEFailure {
    101   bit ShowInSystemHeader = 1;
    102 }
    103 class Warning<string str>   : Diagnostic<str, CLASS_WARNING, SEV_Warning>;
    104 class Remark<string str>    : Diagnostic<str, CLASS_REMARK, SEV_Ignored>;
    105 class Extension<string str> : Diagnostic<str, CLASS_EXTENSION, SEV_Ignored>;
    106 class ExtWarn<string str>   : Diagnostic<str, CLASS_EXTENSION, SEV_Warning>;
    107 class Note<string str>      : Diagnostic<str, CLASS_NOTE, SEV_Fatal/*ignored*/>;
    108 
    109 
    110 class DefaultIgnore { Severity DefaultSeverity = SEV_Ignored; }
    111 class DefaultWarn   { Severity DefaultSeverity = SEV_Warning; }
    112 class DefaultError  { Severity DefaultSeverity = SEV_Error; }
    113 class DefaultFatal  { Severity DefaultSeverity = SEV_Fatal; }
    114 class DefaultWarnNoWerror {
    115   bit WarningNoWerror = 1;
    116 }
    117 class DefaultRemark { Severity DefaultSeverity = SEV_Remark; }
    118 
    119 // Definitions for Diagnostics.
    120 include "DiagnosticASTKinds.td"
    121 include "DiagnosticAnalysisKinds.td"
    122 include "DiagnosticCommentKinds.td"
    123 include "DiagnosticCommonKinds.td"
    124 include "DiagnosticDriverKinds.td"
    125 include "DiagnosticFrontendKinds.td"
    126 include "DiagnosticLexKinds.td"
    127 include "DiagnosticParseKinds.td"
    128 include "DiagnosticSemaKinds.td"
    129 include "DiagnosticSerializationKinds.td"
    130 
    131