[llvm-commits] [bug_122] CVS: llvm/lib/VMCore/Module.cpp

LLVM llvm at cs.uiuc.edu
Sun May 16 18:52:00 PDT 2004


Changes in directory llvm/lib/VMCore:

Module.cpp updated: 1.49.2.1 -> 1.49.2.2

---
Log message:

Changes necessary for interface changes to SymbolTable and to reflect that
Type is no long a Value.


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

Index: llvm/lib/VMCore/Module.cpp
diff -u llvm/lib/VMCore/Module.cpp:1.49.2.1 llvm/lib/VMCore/Module.cpp:1.49.2.2
--- llvm/lib/VMCore/Module.cpp:1.49.2.1	Wed May 12 11:33:43 2004
+++ llvm/lib/VMCore/Module.cpp	Sun May 16 18:52:24 2004
@@ -246,11 +246,15 @@
 bool Module::addTypeName(const std::string &Name, const Type *Ty) {
   SymbolTable &ST = getSymbolTable();
 
-  if (ST.lookup(Type::TypeTy, Name)) return true;  // Already in symtab...
-  
-  // Not in symbol table?  Set the name with the Symtab as an argument so the
-  // type knows what to update...
-  ((Value*)Ty)->setName(Name, &ST);
+  Type* OtherType = ST.lookupType(Name);
+  if ( OtherType )
+  {
+    assert( OtherType == Ty && "Attempt to reset a type with a name");
+    return true;
+  }
+
+  // Not in symbol table?  Simply give the type a name in the symbol table.
+  ST.insert(Name,const_cast<Type*>(Ty));
 
   return false;
 }
@@ -259,7 +263,7 @@
 /// null if there is none by that name.
 const Type *Module::getTypeByName(const std::string &Name) const {
   const SymbolTable &ST = getSymbolTable();
-  return cast_or_null<Type>(ST.lookup(Type::TypeTy, Name));
+  return ST.lookupType(Name);
 }
 
 // getTypeName - If there is at least one entry in the symbol table for the
@@ -267,7 +271,7 @@
 //
 std::string Module::getTypeName(const Type *Ty) const {
   const SymbolTable &ST = getSymbolTable();
-  return ST.get_name( (const Value*) Ty );
+  return ST.get_name( Ty );
 }
 
 
@@ -324,3 +328,5 @@
     GVRefMap = 0;
   }
 }
+
+// vim: sw=2





More information about the llvm-commits mailing list