
Clang has some unwritten rules about diagnostic wording regarding things like punctuation and capitalization. This patch documents those rules and adds some tablegen support for checking diagnostics follow the rules. Specifically: tablegen now checks that a diagnostic does not start with a capital letter or end with punctuation, except for the usual exceptions like proper nouns or ending with a question. Now that the code base is clean of such issues, the diagnostics are emitted as an error rather than a warning to ensure that failure to follow these rules is either addressed by an author, or a new exception is added to the checking logic.
28 lines
1.2 KiB
TableGen
28 lines
1.2 KiB
TableGen
// RUN: clang-tblgen -gen-clang-diags-defs -I%S %s -o - 2>&1 | \
|
|
// RUN: FileCheck --strict-whitespace %s
|
|
include "DiagnosticBase.inc"
|
|
|
|
// Test usage of Deferrable and NonDeferrable in diagnostics.
|
|
|
|
def test_default : Error<"this error is non-deferrable by default">;
|
|
// CHECK-DAG: DIAG(test_default, {{.*}}SFINAE_SubstitutionFailure, false, true, true, false, 0)
|
|
|
|
def test_deferrable : Error<"this error is deferrable">, Deferrable;
|
|
// CHECK-DAG: DIAG(test_deferrable, {{.*}} SFINAE_SubstitutionFailure, false, true, true, true, 0)
|
|
|
|
def test_non_deferrable : Error<"this error is non-deferrable">, NonDeferrable;
|
|
// CHECK-DAG: DIAG(test_non_deferrable, {{.*}} SFINAE_SubstitutionFailure, false, true, true, false, 0)
|
|
|
|
let Deferrable = 1 in {
|
|
|
|
def test_let : Error<"this error is deferrable by let">;
|
|
// CHECK-DAG: DIAG(test_let, {{.*}} SFINAE_SubstitutionFailure, false, true, true, true, 0)
|
|
|
|
// Make sure TextSubstitution is allowed in the let Deferrable block.
|
|
def textsub : TextSubstitution<"%select{text1|text2}0">;
|
|
|
|
def test_let2 : Error<"this error is deferrable by let %sub{textsub}0">;
|
|
// CHECK-DAG: DIAG(test_let2, {{.*}} SFINAE_SubstitutionFailure, false, true, true, true, 0)
|
|
|
|
}
|