Assert instead of going into an infinite loop!
authorChris Lattner <sabre@nondot.org>
Sat, 28 Feb 2004 16:31:53 +0000 (16:31 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 28 Feb 2004 16:31:53 +0000 (16:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11946 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/Record.cpp

index 00751a18244a701e0b5d3170ee72391f059d0024..1a60ac489e082171de9f6253ddbb2726daac144d 100644 (file)
@@ -361,11 +361,14 @@ RecTy *VarInit::getFieldType(const std::string &FieldName) const {
 
 Init *VarInit::getFieldInit(Record &R, const std::string &FieldName) const {
   if (RecordRecTy *RTy = dynamic_cast<RecordRecTy*>(getType()))
-    if (const RecordVal *RV = R.getValue(VarName))
-      if (Init *I = RV->getValue()->getFieldInit(R, FieldName))
+    if (const RecordVal *RV = R.getValue(VarName)) {
+      Init *TheInit = RV->getValue();
+      assert(TheInit != this && "Infinite loop detected!");
+      if (Init *I = TheInit->getFieldInit(R, FieldName))
         return I;
       else
         return 0;
+    }
   return 0;
 }