Skip to content

Commit

Permalink
The basic representation of diagnostics information in tablegen forma…
Browse files Browse the repository at this point in the history
…t, plus (uncommented and incomplete) test conversions of the existing def files to this format.

llvm-svn: 66064
  • Loading branch information
Sebastian Redl committed Mar 4, 2009
1 parent b2cd66b commit b1c4d55
Show file tree
Hide file tree
Showing 7 changed files with 989 additions and 0 deletions.
41 changes: 41 additions & 0 deletions clang/include/clang/Basic/Diagnostic.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//===--- Diagnostic.td - C Language Family Diagnostic Handling ------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the TableGen core definitions for the diagnostics
// and diagnostic control.
//
//===----------------------------------------------------------------------===//

// All diagnostics emitted by the compiler are an indirect subclass of this.
class Diagnostic<string text> {
string Component = ?;
string Text = text;
}

class Error<string text> : Diagnostic<text>;
class Note<string text> : Diagnostic<text>;

// Anything that can be controlled by an option subclasses this.
class OptionControlled;

class Warning<string text> : Diagnostic<text>, OptionControlled {
string DefaultMapping = "warning";
}
// Special cases of warnings.
class Extension<string text> : Warning<text> {
let DefaultMapping = "ignore";
}
class ExtWarn<string text> : Warning<text>;



class Option<string name, list<OptionControlled> members> : OptionControlled {
string Name = name;
list<OptionControlled> Members = members;
}
16 changes: 16 additions & 0 deletions clang/include/clang/Basic/DiagnosticASTKinds.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//==--- DiagnosticASTKinds.td - libast diagnostics ------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

let Component = "AST" in {

def note_comma_in_ice : Note<
"C does not permit evaluated commas in an integer constant expression">;
def note_expr_divide_by_zero : Note<"division by zero">;

}
14 changes: 14 additions & 0 deletions clang/include/clang/Basic/DiagnosticAnalysisKinds.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//==--- DiagnosticAnalysisKinds.td - libanalysis diagnostics --------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

let Component = "Analysis" in {

def warn_uninit_val : Warning<"use of uninitialized variable">;

}
52 changes: 52 additions & 0 deletions clang/include/clang/Basic/DiagnosticCommonKinds.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//==--- DiagnosticCommonKinds.td - common diagnostics --------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

//===----------------------------------------------------------------------===//
// Common Helpers
//===----------------------------------------------------------------------===//

let Component = "Common" in {

def note_previous_definition : Note<"previous definition is here">;
def note_previous_declaration : Note<"previous declaration is here">;
def note_previous_implicit_declaration : Note<
"previous implicit declaration is here">;
def note_previous_use : Note<"previous use is here">;
def note_duplicate_case_prev : Note<"previous case defined here">;
def note_forward_declaration : Note<"forward declaration of %0">;
def note_type_being_defined : Note<
"definition of %0 is not complete until the closing '}'">;
def note_matching : Note<"to match this '%0'">;
def note_using_decl : Note<"using">;
def note_also_found_decl : Note<"also found">;

def err_expected_colon : Error<"expected ':'">;

def err_no_declarators : Error<"declaration does not declare anything">;
def err_param_redefinition : Error<"redefinition of parameter %0">;
def err_invalid_storage_class_in_func_decl : Error<
"invalid storage class specifier in function declarator">;
def err_expected_namespace_name : Error<"expected namespace name">;

def ext_longlong : Extension<
"'long long' is an extension when C99 mode is not enabled">;
def warn_integer_too_large : Warning<
"integer constant is too large for its type">;
def warn_integer_too_large_for_signed : Warning<
"integer constant is so large that it is unsigned">;

def note_invalid_subexpr_in_ice : Note<
"subexpression not valid in an integer constant expression">;

def pp_macro_not_used : Warning<"macro is not used">;
def err_pp_I_dash_not_supported : Error<
"-I- not supported, please use -iquote instead">;
def warn_pp_undef_identifier : Warning<"%0 is not defined, evaluates to 0">;

}
210 changes: 210 additions & 0 deletions clang/include/clang/Basic/DiagnosticLexKinds.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
//==--- DiagnosticLexKinds.td - liblex diagnostics ------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

//===----------------------------------------------------------------------===//
// Lexer Diagnostics
//===----------------------------------------------------------------------===//

let Component = "Lex" in {

def null_in_string : Warning<"null character(s) preserved in string literal">;
def null_in_char : Warning<"null character(s) preserved in character literal">;
def null_in_file : Warning<"null character ignored">;
def warn_nested_block_comment : Warning<"'/*' within block comment">;
def escaped_newline_block_comment_end : Warning<
"escaped newline between */ characters at block comment end">;
def backslash_newline_space : Warning<
"backslash and newline separated by space">;

def trigraph_ignored : Warning<"trigraph ignored">;
def trigraph_ignored_block_comment : Warning<
"ignored trigraph would end block comment">;
def trigraph_ends_block_comment : Warning<"trigraph ends block comment">;
def trigraph_converted : Warning<"trigraph converted to '%0' character">;

def ext_multi_line_bcpl_comment : Extension<"multi-line // comment">;
def ext_bcpl_comment : Extension<
"// comments are not allowed in this language">;
def ext_no_newline_eof : Extension<"no newline at end of file">;
def ext_backslash_newline_eof : Extension<"backslash-newline at end of file">;
def ext_dollar_in_identifier : Extension<"'$' in identifier">;
def charize_microsoft_ext : Extension<"@# is a microsoft extension">;

def ext_token_used : Extension<"extension used">;

def err_unterminated_string : Error<"missing terminating '\"' character">;
def err_unterminated_char : Error<"missing terminating ' character">;
def err_unterminated_angled_string : Error<"missing terminating '>' character">;
def err_empty_character : Error<"empty character constant">;
def err_unterminated_block_comment : Error<"unterminated /* comment">;
def err_invalid_character_to_charify : Error<
"invalid argument to convert to character">;

def ext_nonstandard_escape : Extension<
"use of non-standard escape character '\\%0'">;
def ext_unknown_escape : Extension<"unknown escape sequence '\\%0'">;
def err_hex_escape_no_digits : Error<"\\x used with no following hex digits">;
def err_invalid_decimal_digit : Error<"invalid digit '%0' in decimal constant">;
def err_invalid_binary_digit : Error<"invalid digit '%0' in binary constant">;
def err_invalid_octal_digit : Error<"invalid digit '%0' in octal constant">;
def err_invalid_suffix_integer_constant : Error<
"invalid suffix '%0' on integer constant">;
def err_invalid_suffix_float_constant : Error<
"invalid suffix '%0' on floating constant">;
def warn_extraneous_wide_char_constant : Warning<
"extraneous characters in wide character constant ignored">;
def warn_char_constant_too_large : Warning<
"character constant too long for its type">;
def err_exponent_has_no_digits : Error<"exponent has no digits">;
def ext_imaginary_constant : Extension<"imaginary constants are an extension">;
def err_hexconstant_requires_exponent : Error<
"hexadecimal floating constants require an exponent">;
def ext_hexconstant_invalid : Extension<
"hexadecimal floating constants are a C99 feature">;
def ext_binary_literal : Extension<"binary integer literals are an extension">;
def err_pascal_string_too_long : Error<"Pascal string is too long">;
def warn_octal_escape_too_large : ExtWarn<"octal escape sequence out of range">;
def warn_hex_escape_too_large : ExtWarn<"hex escape sequence out of range">;


def pp_hash_warning : Warning<"#warning%0">;
def pp_include_next_in_primary : Warning<
"#include_next in primary source file">;
def pp_include_next_absolute_path : Warning<"#include_next with absolute path">;
def ext_c99_whitespace_required_after_macro_name : Warning<
"ISO C99 requires whitespace after the macro name">;
def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">;
def pp_pragma_sysheader_in_main_file : Warning<
"#pragma system_header ignored in main file">;
def pp_poisoning_existing_macro : Warning<"poisoning existing macro">;
def pp_out_of_date_dependency : Warning<
"current file is older than dependency %0">;
def pp_undef_builtin_macro : Warning<"undefining builtin macro">;
def pp_redef_builtin_macro : Warning<"redefining builtin macro">;
def pp_invalid_string_literal : Warning<
"invalid string literal, ignoring final '\\'">;
def warn_pp_expr_overflow : Warning<
"integer overflow in preprocessor expression">;
def warn_pp_convert_lhs_to_positive : Warning<
"left side of operator converted from negative value to unsigned: %0">;
def warn_pp_convert_rhs_to_positive : Warning<
"right side of operator converted from negative value to unsigned: %0">;

def ext_pp_import_directive : Extension<"#import is a language extension">;
def ext_pp_ident_directive : Extension<"#ident is a language extension">;
def ext_pp_include_next_directive : Extension<
"#include_next is a language extension">;
def ext_pp_warning_directive : Extension<"#warning is a language extension">;
def ext_pp_extra_tokens_at_eol : Extension<
"extra tokens at end of %0 directive">;
def ext_pp_comma_expr : Extension<"comma operator in operand of #if">;
def ext_pp_bad_vaargs_use : Extension<
"__VA_ARGS__ can only appear in the expansion of a C99 variadic macro">;
def ext_pp_macro_redef : Extension<"%0 macro redefined">;
def ext_variadic_macro : Extension<"variadic macros were introduced in C99">;
def ext_named_variadic_macro : Extension<
"named variadic macros are a GNU extension">;
def ext_embedded_directive : Extension<
"embedding a directive within macro arguments is not portable">;
def ext_missing_varargs_arg : Extension<
"varargs argument missing, but tolerated as an extension">;
def ext_empty_fnmacro_arg : Extension<
"empty macro arguments were standardized in C99">;

def ext_pp_base_file : Extension<"__BASE_FILE__ is a language extension">;
def ext_pp_include_level : Extension<
"__INCLUDE_LEVEL__ is a language extension">;
def ext_pp_timestamp : Extension<"__TIMESTAMP__ is a language extension">;

def err_pp_invalid_directive : Error<"invalid preprocessing directive">;
def err_pp_hash_error : Error<"#error%0">;
def err_pp_file_not_found : Error<"'%0' file not found">;
def err_pp_empty_filename : Error<"empty filename">;
def err_pp_include_too_deep : Error<"#include nested too deeply">;
def err_pp_expects_filename : Error<"expected \"FILENAME\" or <FILENAME>">;
def err_pp_macro_not_identifier : Error<"macro names must be identifiers">;
def err_pp_missing_macro_name : Error<"macro name missing">;
def err_pp_missing_rparen_in_macro_def : Error<
"missing ')' in macro parameter list">;
def err_pp_invalid_tok_in_arg_list : Error<
"invalid token in macro parameter list">;
def err_pp_expected_ident_in_arg_list : Error<
"expected identifier in macro parameter list">;
def err_pp_expected_comma_in_arg_list : Error<
"expected comma in macro parameter list">;
def err_pp_duplicate_name_in_arg_list : Error<
"duplicate macro parameter name %0">;
def err_pp_stringize_not_parameter : Error<
"'#' is not followed by a macro parameter">;
def err_pp_malformed_ident : Error<"invalid #ident directive">;
def err_pp_unterminated_conditional : Error<
"unterminated conditional directive">;
def pp_err_else_after_else : Error<"#else after #else">;
def pp_err_elif_after_else : Error<"#elif after #else">;
def pp_err_else_without_if : Error<"#else without #if">;
def pp_err_elif_without_if : Error<"#elif without #if">;
def err_pp_endif_without_if : Error<"#endif without #if">;
def err_pp_expected_value_in_expr : Error<"expected value in expression">;
def err_pp_missing_val_before_operator : Error<"missing value before operator">;
def err_pp_expected_rparen : Error<"expected ')' in preprocessor expression">;
def err_pp_expected_eol : Error<
"expected end of line in preprocessor expression">;
def err_pp_defined_requires_identifier : Error<
"operator 'defined' requires an identifier">;
def err_pp_missing_rparen : Error<"missing ')' after 'defined'">;
def err_pp_colon_without_question : Error<"':' without preceding '?'">;
def err_pp_division_by_zero : Error<
"division by zero in preprocessor expression">;
def err_pp_remainder_by_zero : Error<
"remainder by zero in preprocessor expression">;
def err_pp_expr_bad_token_binop : Error<
"token is not a valid binary operator in a preprocessor subexpression">;
def err_pp_expr_bad_token_start_expr : Error<
"invalid token at start of a preprocessor expression">;
def err_pp_invalid_poison : Error<"can only poison identifier tokens">;
def err_pp_used_poisoned_id : Error<"attempt to use a poisoned identifier">;
def err__Pragma_malformed : Error<
"_Pragma takes a parenthesized string literal">;
def err_pragma_comment_malformed : Error<
"pragma comment requires parenthesized identifier and optional string">;
def err_pragma_comment_unknown_kind : Error<"unknown kind of pragma comment">;
def err_defined_macro_name : Error<"'defined' cannot be used as a macro name">;
def err_paste_at_start : Error<
"'##' cannot appear at start of macro expansion">;
def err_paste_at_end : Error<"'##' cannot appear at end of macro expansion">;
def ext_paste_comma : Extension<
"Use of comma pasting extension is non-portable">;
def err_unterm_macro_invoc : Error<
"unterminated function-like macro invocation">;
def err_too_many_args_in_macro_invoc : Error<
"too many arguments provided to function-like macro invocation">;
def err_too_few_args_in_macro_invoc : Error<
"too few arguments provided to function-like macro invocation">;
def err_pp_bad_paste : Error<
"pasting formed '%0', an invalid preprocessing token">;
def err_pp_operator_used_as_macro_name : Error<
"C++ operator '%0' cannot be used as a macro name">;
def err_pp_illegal_floating_literal : Error<
"floating point literal in preprocessor expression">;
def err_pp_line_requires_integer : Error<
"#line directive requires a positive integer argument">;
def err_pp_line_invalid_filename : Error<
"invalid filename for #line directive">;
def err_pp_linemarker_requires_integer : Error<
"line marker directive requires a positive integer argument">;
def err_pp_linemarker_invalid_filename : Error<
"invalid filename for line marker directive">;
def err_pp_linemarker_invalid_flag : Error<
"invalid flag line marker directive">;
def err_pp_linemarker_invalid_pop : Error<
"invalid line marker flag '2': cannot pop empty include stack">;
def ext_pp_line_too_big : Extension<
"C requires #line number to be less than %0, allowed as extension">;

}

0 comments on commit b1c4d55

Please sign in to comment.