[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y

Chris Lattner lattner at cs.uiuc.edu
Tue Jul 13 01:12:50 PDT 2004



Changes in directory llvm/lib/AsmParser:

llvmAsmParser.y updated: 1.175 -> 1.176

---
Log message:

Inline the now trivial setValueNameInternal function into both callers


---
Diffs of the changes:  (+10 -13)

Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.175 llvm/lib/AsmParser/llvmAsmParser.y:1.176
--- llvm/lib/AsmParser/llvmAsmParser.y:1.175	Tue Jul 13 03:10:10 2004
+++ llvm/lib/AsmParser/llvmAsmParser.y	Tue Jul 13 03:12:39 2004
@@ -476,16 +476,6 @@
   }
 }
 
-
-static void setValueNameInternal(Value *V, const std::string &Name,
-                                 SymbolTable &ST) {
-  if (V->getType() == Type::VoidTy) 
-    ThrowException("Can't assign name '" + Name + "' to value with void type!");
-
-  // Set the name
-  V->setName(Name, &ST);
-}
-
 // setValueName - Set the specified value to the name given.  The name may be
 // null potentially, in which case this is a noop.  The string passed in is
 // assumed to be a malloc'd string buffer, and is free'd by this function.
@@ -494,6 +484,9 @@
   if (NameStr) {
     std::string Name(NameStr);      // Copy string
     free(NameStr);                  // Free old string
+
+    if (V->getType() == Type::VoidTy) 
+      ThrowException("Can't assign name '" + Name+"' to value with void type!");
     
     assert(inFunctionScope() && "Must be in function scope!");
     SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
@@ -501,7 +494,8 @@
       ThrowException("Redefinition of value named '" + Name + "' in the '" +
                      V->getType()->getDescription() + "' type plane!");
     
-    setValueNameInternal(V, Name, ST);
+    // Set the name.
+    V->setName(Name, &ST);
   }
 }
 
@@ -515,6 +509,8 @@
 // for the typeplane, false is returned.
 //
 static bool setValueNameMergingDuplicates(Value *V, char *NameStr) {
+  assert(V->getType() != Type::VoidTy && "Global or constant of type void?");
+
   if (NameStr == 0) return false;
 
   std::string Name(NameStr);      // Copy string
@@ -558,8 +554,9 @@
     ThrowException("Redefinition of value named '" + Name + "' in the '" +
 		   V->getType()->getDescription() + "' type plane!");
   }
-  
-  setValueNameInternal(V, Name, ST);
+
+  // Set the name.
+  V->setName(Name, &ST);
   return false;
 }
 





More information about the llvm-commits mailing list