1 // RUN: llvm-tblgen --no-warn-on-unused-template-args %s | FileCheck %s
7 class A_check<string name>{
8 int exists = !exists<A>(name);
11 def a0_exists : A_check<"a0">;
12 def a1_missing : A_check<"a1">;
15 // Subclasses are allowed.
19 class B_check<string name> {
20 int exists = !exists<B>(name);
25 def sub_exists : B_check<"sub">;
26 def a0_is_not_sub_of_B : B_check<"a0">;
29 // Self-references are allowed.
31 class Self_check<string name> {
32 int exists = !exists<Self_check>(name);
35 def self_reference : Self_check<"self_reference">; // Self-reference
36 // There is no record called `current` in current context though we will define it below.
37 def current_missing : Self_check<"current">;
38 def current : Self_check<"current">;
41 // Check that conditional definitions dependent on the resolution of an
42 // exists clause work as expected.
43 // Reminder: a0 exists, a1 does not.
47 if !exists<A>("a0") then
49 if !exists<A>("a1") then
51 foreach e = ["a0", "a1"] in {
53 def for_exists_ # e: C;
56 foreach e = ["a0", "a1"] in {
61 defm multiclass_exists : mc<>;
64 // CHECK: def a0_exists {
65 // CHECK: int exists = 1;
68 // CHECK: def a0_is_not_sub_of_B {
69 // CHECK: int exists = 0;
72 // CHECK: def a1_missing {
73 // CHECK: int exists = 0;
76 // CHECK: def current {
77 // CHECK: int exists = 1;
80 // `current` doesn't exist because we define it below `current_missing`.
81 // CHECK: def current_missing {
82 // CHECK: int exists = 0;
85 // CHECK: def for_exists_a0 {
86 // CHECK: int exists = 1;
88 // CHECK: def if_exists {
89 // CHECK: int exists = 1;
91 // CHECK: def multiclass_exists_a0 {
92 // CHECK: int exists = 1;
95 // CHECK: def self_reference {
96 // CHECK: int exists = 1;
99 // CHECK: def sub_exists {
100 // CHECK: int exists = 1;