[llvm-commits] [hlvm] r38357 - /hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp

Reid Spencer reid at x10sys.com
Sat Jul 7 17:02:38 PDT 2007


Author: reid
Date: Sat Jul  7 19:02:38 2007
New Revision: 38357

URL: http://llvm.org/viewvc/llvm-project?rev=38357&view=rev
Log:
Fix string type and string constant generation.
Emit the program last so there's no forward references to functions.

Modified:
    hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp

Modified: hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp?rev=38357&r1=38356&r2=38357&view=diff

==============================================================================
--- hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp (original)
+++ hlvm/trunk/tools/hlvm-gentestcase/Generate.cpp Sat Jul  7 19:02:38 2007
@@ -105,7 +105,8 @@
   Type* result = 0;
   NodeIDs id = NodeIDs(randRange(FirstTypeID,LastTypeID));
   if (--limit == 0)
-    id = BooleanTypeID;
+    return ast->getPrimitiveType(BooleanTypeID);
+
   switch (id) {
     case BooleanTypeID:
     case CharacterTypeID:
@@ -128,12 +129,11 @@
     case Float44TypeID:
     case Float64TypeID:
     case Float80TypeID:
+    case StringTypeID:
       return ast->getPrimitiveType(id);
     case Float128TypeID:
       return ast->getPrimitiveType(Float64TypeID);
-
     case AnyTypeID:
-    case StringTypeID:
     case BufferTypeID:
     case StreamTypeID:
     case TextTypeID:
@@ -163,7 +163,8 @@
       Locator* loc = getLocator();
       std::string name = "enum_" + utostr(line);
       EnumerationType* E = ast->new_EnumerationType(name,loc);
-      for (unsigned i = 0; i < Complexity; i++)
+      unsigned numEnums = randRange(1,Complexity,true);
+      for (unsigned i = 0; i < numEnums; i++)
         E->addEnumerator(name + "_" + utostr(i));
       result = E;
       break;
@@ -355,21 +356,17 @@
         std::string("cf32_")+utostr(line),val_str,Ty,loc);
       break;
     }
-    case AnyTypeID:
-    {
-      C = ast->new_ConstantAny(
-        std::string("cany_")+utostr(line),
-          cast<ConstantValue>(genValue(genType(),true)),loc);
-      break;
-    }
     case StringTypeID:
     {
       std::string val;
-      for (unsigned i = 0 ; i < Complexity*Size; i++)
+      unsigned numChars = randRange(1,Size+Complexity,true);
+      for (unsigned i = 0 ; i < numChars; i++)
         val += char(randRange(35,126));
       C = ast->new_ConstantString(
         std::string("cstr_")+utostr(line),val,loc);
+      break;
     }
+    case AnyTypeID:
     case BufferTypeID:
     case StreamTypeID:
     case TextTypeID:
@@ -592,7 +589,6 @@
   uri = ast->new_URI(pubid);
   bundle = ast->new_Bundle(bundleName,getLocator());
   program = ast->new_Program(bundleName,getLocator());
-  program->setParent(bundle);
   Block* blk = ast->new_Block(getLocator());
   blk->setParent(program);
   for (unsigned i = 0; i < Size; i++) {
@@ -612,5 +608,6 @@
 
   ReturnOp* ret = ast->new_NilaryOp<ReturnOp>(getLocator());
   ret->setParent(blk);
+  program->setParent(bundle);
   return ast;
 }





More information about the llvm-commits mailing list