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 }
     52 class InGroup<DiagGroup G> { DiagGroup Group = G; }
     53 //class IsGroup<string Name> { DiagGroup Group = DiagGroup<Name>; }
     54 
     55 
     56 // This defines all of the named diagnostic categories.
     57 include "DiagnosticCategories.td"
     58 
     59 // This defines all of the named diagnostic groups.
     60 include "DiagnosticGroups.td"
     61 
     62 
     63 // All diagnostics emitted by the compiler are an indirect subclass of this.
     64 class Diagnostic<string text, DiagClass DC, Severity defaultmapping> {
     65   /// Component is specified by the file with a big let directive.
     66   string         Component = ?;
     67   string         Text = text;
     68   DiagClass      Class = DC;
     69   SFINAEResponse SFINAE = SFINAE_Suppress;
     70   bit            AccessControl = 0;
     71   bit            WarningNoWerror = 0;
     72   bit            ShowInSystemHeader = 0;
     73   Severity       DefaultSeverity = defaultmapping;
     74   DiagGroup      Group;
     75   string         CategoryName = "";
     76 }
     77 
     78 class SFINAEFailure {
     79   SFINAEResponse SFINAE = SFINAE_SubstitutionFailure;
     80 }
     81 class NoSFINAE {
     82   SFINAEResponse SFINAE = SFINAE_Report;
     83 }
     84 class AccessControl {
     85   SFINAEResponse SFINAE = SFINAE_AccessControl;
     86 }
     87 
     88 class ShowInSystemHeader {
     89   bit ShowInSystemHeader = 1;
     90 }
     91 
     92 class SuppressInSystemHeader {
     93   bit ShowInSystemHeader = 0;
     94 }
     95 
     96 // FIXME: ExtWarn and Extension should also be SFINAEFailure by default.
     97 class Error<string str>     : Diagnostic<str, CLASS_ERROR, SEV_Error>, SFINAEFailure {
     98   bit ShowInSystemHeader = 1;
     99 }
    100 class Warning<string str>   : Diagnostic<str, CLASS_WARNING, SEV_Warning>;
    101 class Remark<string str>    : Diagnostic<str, CLASS_REMARK, SEV_Ignored>;
    102 class Extension<string str> : Diagnostic<str, CLASS_EXTENSION, SEV_Ignored>;
    103 class ExtWarn<string str>   : Diagnostic<str, CLASS_EXTENSION, SEV_Warning>;
    104 class Note<string str>      : Diagnostic<str, CLASS_NOTE, SEV_Fatal/*ignored*/>;
    105 
    106 
    107 class DefaultIgnore { Severity DefaultSeverity = SEV_Ignored; }
    108 class DefaultWarn   { Severity DefaultSeverity = SEV_Warning; }
    109 class DefaultError  { Severity DefaultSeverity = SEV_Error; }
    110 class DefaultFatal  { Severity DefaultSeverity = SEV_Fatal; }
    111 class DefaultWarnNoWerror {
    112   bit WarningNoWerror = 1;
    113 }
    114 class DefaultRemark { Severity DefaultSeverity = SEV_Remark; }
    115 
    116 // Definitions for Diagnostics.
    117 include "DiagnosticASTKinds.td"
    118 include "DiagnosticAnalysisKinds.td"
    119 include "DiagnosticCommentKinds.td"
    120 include "DiagnosticCommonKinds.td"
    121 include "DiagnosticDriverKinds.td"
    122 include "DiagnosticFrontendKinds.td"
    123 include "DiagnosticLexKinds.td"
    124 include "DiagnosticParseKinds.td"
    125 include "DiagnosticSemaKinds.td"
    126 include "DiagnosticSerializationKinds.td"
    127 
    128