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

LLVM llvm at cs.uiuc.edu
Tue May 25 10:24:58 PDT 2004


Changes in directory llvm/lib/VMCore:

SymbolTable.cpp updated: 1.43 -> 1.44

---
Log message:

Made it illegal to pass a Type* through one of the Value* interfaces. The
SymbolTable will now assert if this is done. This didn't find any incorrect
usage of SymbolTable but will prevent future mistakes until Type != Value.


---
Diffs of the changes:  (+4 -0)

Index: llvm/lib/VMCore/SymbolTable.cpp
diff -u llvm/lib/VMCore/SymbolTable.cpp:1.43 llvm/lib/VMCore/SymbolTable.cpp:1.44
--- llvm/lib/VMCore/SymbolTable.cpp:1.43	Tue May 25 03:52:42 2004
+++ llvm/lib/VMCore/SymbolTable.cpp	Tue May 25 10:20:47 2004
@@ -93,6 +93,7 @@
 // Remove a value
 void SymbolTable::remove(Value *N) {
   assert(N->hasName() && "Value doesn't have name!");
+  assert(!isa<Type>(N) && "Can't remove types through this interface.");
   if (InternallyInconsistent) return;
 
   plane_iterator PI = pmap.find(N->getType());
@@ -109,6 +110,7 @@
          Entry != Plane->second.end() && "Invalid entry to remove!");
 
   Value *Result = Entry->second;
+  assert(!isa<Type>(Result) && "Can't remove types through this interface.");
   const Type *Ty = Result->getType();
 #if DEBUG_SYMBOL_TABLE
   dump();
@@ -181,6 +183,7 @@
 // insertEntry - Insert a value into the symbol table with the specified name.
 void SymbolTable::insertEntry(const std::string &Name, const Type *VTy,
                               Value *V) {
+  assert(!isa<Type>(V) && "Can't insert types through this interface.");
   // Check to see if there is a naming conflict.  If so, rename this value!
   if (lookup(VTy, Name)) {
     std::string UniqueName = getUniqueName(VTy, Name);
@@ -259,6 +262,7 @@
 
 // Get the name of a value
 std::string SymbolTable::get_name( const Value* V ) const {
+  assert(!isa<Type>(V) && "Can't get name of types through this interface.");
   value_const_iterator VI = this->value_begin( V->getType() );
   value_const_iterator VE = this->value_end( V->getType() );
 





More information about the llvm-commits mailing list