[TableGen] Simplify some code. NFC
authorCraig Topper <craig.topper@gmail.com>
Thu, 14 May 2015 05:53:59 +0000 (05:53 +0000)
committerCraig Topper <craig.topper@gmail.com>
Thu, 14 May 2015 05:53:59 +0000 (05:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237342 91177308-0d34-0410-b5e6-96231b3b80d8

lib/TableGen/Record.cpp

index 9c8a06f..a922917 100644 (file)
@@ -794,14 +794,10 @@ Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
   }
   case EMPTY: {
     if (ListInit *LHSl = dyn_cast<ListInit>(LHS)) {
-      if (LHSl->empty())
-        return IntInit::get(1);
-      return IntInit::get(0);
+      return IntInit::get(!!LHSl->empty());
     }
     if (StringInit *LHSs = dyn_cast<StringInit>(LHS)) {
-      if (LHSs->getValue().empty())
-        return IntInit::get(1);
-      return IntInit::get(0);
+      return IntInit::get(!!LHSs->getValue().empty());
     }
 
     break;
@@ -1134,9 +1130,8 @@ Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
   }
 
   case FOREACH: {
-    Init *Result = ForeachHelper(LHS, MHS, RHS, getType(),
-                                 CurRec, CurMultiClass);
-    if (Result)
+    if (Init *Result = ForeachHelper(LHS, MHS, RHS, getType(),
+                                     CurRec, CurMultiClass))
       return Result;
     break;
   }