1// RUN: llvm-tblgen --no-warn-on-unused-template-args %s | FileCheck %s 2// XFAIL: vg_leak 3 4class A; 5def a0 : A; 6 7class A_check<string name>{ 8 int exists = !exists<A>(name); 9} 10 11def a0_exists : A_check<"a0">; 12def a1_missing : A_check<"a1">; 13 14 15// Subclasses are allowed. 16 17class B; 18class SubOfB : B; 19class B_check<string name> { 20 int exists = !exists<B>(name); 21} 22 23def sub : SubOfB; 24 25def sub_exists : B_check<"sub">; 26def a0_is_not_sub_of_B : B_check<"a0">; 27 28 29// Self-references are allowed. 30 31class Self_check<string name> { 32 int exists = !exists<Self_check>(name); 33} 34 35def self_reference : Self_check<"self_reference">; // Self-reference 36// There is no record called `current` in current context though we will define it below. 37def current_missing : Self_check<"current">; 38def current : Self_check<"current">; 39 40 41// Check that conditional definitions dependent on the resolution of an 42// exists clause work as expected. 43// Reminder: a0 exists, a1 does not. 44class C { 45 int exists = 1; 46} 47if !exists<A>("a0") then 48 def if_exists : C; 49if !exists<A>("a1") then 50 def if_no_exists: C; 51foreach e = ["a0", "a1"] in { 52 if !exists<A>(e) then 53 def for_exists_ # e: C; 54} 55multiclass mc { 56 foreach e = ["a0", "a1"] in { 57 if !exists<A>(e) then 58 def _ # e: C; 59 } 60} 61defm multiclass_exists : mc<>; 62 63 64// CHECK: def a0_exists { 65// CHECK: int exists = 1; 66// CHECK: } 67 68// CHECK: def a0_is_not_sub_of_B { 69// CHECK: int exists = 0; 70// CHECK: } 71 72// CHECK: def a1_missing { 73// CHECK: int exists = 0; 74// CHECK: } 75 76// CHECK: def current { 77// CHECK: int exists = 1; 78// CHECK: } 79 80// `current` doesn't exist because we define it below `current_missing`. 81// CHECK: def current_missing { 82// CHECK: int exists = 0; 83// CHECK: } 84 85// CHECK: def for_exists_a0 { 86// CHECK: int exists = 1; 87// CHECK: } 88// CHECK: def if_exists { 89// CHECK: int exists = 1; 90// CHECK: } 91// CHECK: def multiclass_exists_a0 { 92// CHECK: int exists = 1; 93// CHECK: } 94 95// CHECK: def self_reference { 96// CHECK: int exists = 1; 97// CHECK: } 98 99// CHECK: def sub_exists { 100// CHECK: int exists = 1; 101// CHECK: } 102