Index: llvm/include/llvm/TableGen/Record.h =================================================================== --- llvm/include/llvm/TableGen/Record.h +++ llvm/include/llvm/TableGen/Record.h @@ -905,7 +905,9 @@ // possible to fold. Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const override; - bool isComplete() const override { return false; } + bool isComplete() const override { + return LHS->isComplete() && MHS->isComplete() && RHS->isComplete(); + } Init *resolveReferences(Record &R, const RecordVal *RV) const override; Index: llvm/test/TableGen/if.td =================================================================== --- llvm/test/TableGen/if.td +++ llvm/test/TableGen/if.td @@ -56,6 +56,23 @@ // CHECK: def D8 // CHECK-NEXT: bits<2> val = { 0, 0 }; +// Make sure !if gets evaluated throughout multiple layers of inheritance. +class getInt { + int ret = !if(c, 0, 1); +} +class I1 { + int i = getInt.ret; +} +class I2 : I1; + +// CHECK: def DI1 { // I1 +// CHECK-NEXT: int i = 0; +def DI1: I1<1>; + +// CHECK: def DI2 { // I1 I2 +// CHECK-NEXT: int i = 0; +def DI2: I2<1>; + // CHECK: def One // CHECK-NEXT: list first = [1, 2, 3]; // CHECK-NEXT: list rest = [1, 2, 3];