Clang Project

clang_source_code/test/TableGen/text-substitution.td
1// RUN: clang-tblgen -gen-clang-diags-defs -I%S %s -o - 2>&1 | \
2// RUN:    FileCheck --strict-whitespace %s
3include "DiagnosticBase.inc"
4
5def yes_no : TextSubstitution<"%select{yes|no}0">;
6def says_yes : TextSubstitution<"%1 says %sub{yes_no}0">;
7
8
9def sub_test_rewrite : TextSubstitution<
10  "SELECT! %select{one|two}3. "
11  "DIFF! %diff{$ is $|or not}0,1. "
12  "PLURAL! %plural{0:zero items|[1,2]:one or two item|:multiple items}2. "
13  "ORDINAL! %ordinal1. "
14  "S! item%s2. "
15  "Q! %q4. "
16  "PLACEHOLDER! %5."
17  "OBJCCLASS! %objcclass0. "
18  "OBJCINSTANCE! %objcinstance1. ">;
19
20// CHECK: DIAG(test_rewrite,
21// CHECK-SAME: SELECT! %select{one|two}2.
22// CHECK-SAME: DIFF! %diff{$ is $|or not}5,4.
23// CHECK-SAME: PLURAL! %plural{0:zero items|[1,2]:one or two item|:multiple items}3.
24// CHECK-SAME: ORDINAL! %ordinal4.
25// CHECK-SAME: S! item%s3.
26// CHECK-SAME: Q! %q1.
27// CHECK-SAME: PLACEHOLDER! %0.OBJCCLASS!
28// CHECK-SAME: %objcclass5. OBJCINSTANCE!
29// CHECK-SAME: %objcinstance4.  DONE!",
30def test_rewrite: Error<"%sub{sub_test_rewrite}5,4,3,2,1,0 DONE!">;
31
32def test_sub_basic : Error<"%sub{yes_no}0">;
33// CHECK: test_sub_basic
34// CHECK-SAME: "%select{yes|no}0",
35
36def test_sub_nested : Error<"%sub{says_yes}2,4">;
37// CHECK: test_sub_nested
38// CHECK-SAME: "%4 says %select{yes|no}2",
39