brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · d0a83e7 Raw
51 lines · plain
1// RUN: llvm-tblgen %s | FileCheck %s2// XFAIL: vg_leak3 4class A {}5class B<A a> {6  A ba = a;7}8 9multiclass M0<string s> {10  def _m0 : B<!cast<A>(s)>;11 12  // Uncomment to test that !cast will eventually fail if the record it refers13  // to does not exist by the time we instantiate this record from the top14  // level.15  //def _m1 : B<!cast<A>(s#"X")>;16}17 18multiclass M1<string s> {19  def _r1 : A;20  // It would be nice if we could refer to _r1's name without having to pass it21  // explicitly via 's'.22  defm _m1: M0<s # "_r1">;23}24 25multiclass M2 {26  def _x : A {27    string n = NAME;28  }29 30  def _y : B<!cast<A>(NAME # "_x")>;31 32  // This used to throw an error during multiclass parsing as NAME was not33  // recognized when parsing the template arguments.34  defm NAME: M1<NAME>;35}36defm d0: M2;37// CHECK-LABEL: def d0_m1_m038// CHECK: A ba = d0_r1;39//40// CHECK-LABEL: def d0_x {41// CHECK: string n = "d0";42//43// CHECK-LABEL: def d0_y {44// CHECK: A ba = d0_x;45 46// This always works, because d1_r1 is instantiated before d1_m1 which would47// attempt to !cast to it.48defm d1: M1<"d1">;49// CHECK-LABEL: def d1_m1_m050// CHECK: A ba = d1_r1;51