From 477bf62048238950338421d1b6bd1ed0a82d35ea Mon Sep 17 00:00:00 2001 From: Bruno Cardoso Lopes Date: Thu, 17 Jun 2010 01:50:39 +0000 Subject: [PATCH] Fix the handling of !if result, avoiding null results for non 'int'. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106201 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/Record.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index 53a4abdaf2b..f0147d328b8 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -981,8 +981,9 @@ Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) { } case IF: { - IntInit *LHSi = - dynamic_cast(LHS->convertInitializerTo(new IntRecTy())); + IntInit *LHSi = dynamic_cast(LHS); + if (Init *I = LHS->convertInitializerTo(new IntRecTy())) + LHSi = dynamic_cast(I); if (LHSi) { if (LHSi->getValue()) { return MHS; @@ -1001,8 +1002,9 @@ Init *TernOpInit::resolveReferences(Record &R, const RecordVal *RV) { Init *lhs = LHS->resolveReferences(R, RV); if (Opc == IF && lhs != LHS) { - IntInit *Value = - dynamic_cast(LHS->convertInitializerTo(new IntRecTy())); + IntInit *Value = dynamic_cast(lhs); + if (Init *I = lhs->convertInitializerTo(new IntRecTy())) + Value = dynamic_cast(I); if (Value != 0) { // Short-circuit if (Value->getValue()) { -- 2.34.1