[llvm-commits] CVS: llvm/lib/VMCore/SymbolTable.cpp
LLVM
llvm at cs.uiuc.edu
Sun Jul 4 06:56:01 PDT 2004
Changes in directory llvm/lib/VMCore:
SymbolTable.cpp updated: 1.45 -> 1.46
---
Log message:
Constify SymbolTable's use of Type* so that it never modifies them.
---
Diffs of the changes: (+8 -11)
Index: llvm/lib/VMCore/SymbolTable.cpp
diff -u llvm/lib/VMCore/SymbolTable.cpp:1.45 llvm/lib/VMCore/SymbolTable.cpp:1.46
--- llvm/lib/VMCore/SymbolTable.cpp:1.45 Fri Jun 4 19:03:27 2004
+++ llvm/lib/VMCore/SymbolTable.cpp Sun Jul 4 06:55:08 2004
@@ -17,6 +17,7 @@
#include "llvm/Module.h"
#include "Support/StringExtras.h"
#include <algorithm>
+#include <iostream>
using namespace llvm;
@@ -86,14 +87,13 @@
Type* SymbolTable::lookupType( const std::string& Name ) const {
type_const_iterator TI = tmap.find( Name );
if ( TI != tmap.end() )
- return TI->second;
+ return const_cast<Type*>(TI->second);
return 0;
}
// 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());
@@ -110,7 +110,6 @@
Entry != Plane->second.end() && "Invalid entry to remove!");
Value *Result = Entry->second;
- assert(!isa<Type>(Result) && "Can't remove types through this interface.");
#if DEBUG_SYMBOL_TABLE
dump();
std::cerr << " Removing Value: " << Result->getName() << "\n";
@@ -139,7 +138,7 @@
// remove - Remove a type
-void SymbolTable::remove(Type* Ty ) {
+void SymbolTable::remove(const Type* Ty ) {
type_iterator TI = this->type_begin();
type_iterator TE = this->type_end();
@@ -157,7 +156,7 @@
if (InternallyInconsistent) return 0;
assert( Entry != tmap.end() && "Invalid entry to remove!");
- Type* Result = Entry->second;
+ const Type* Result = Entry->second;
#if DEBUG_SYMBOL_TABLE
dump();
@@ -175,14 +174,13 @@
cast<DerivedType>(Result)->removeAbstractTypeUser(this);
}
- return Result;
+ return const_cast<Type*>(Result);
}
// 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);
@@ -225,7 +223,7 @@
// insertEntry - Insert a value into the symbol table with the specified
// name...
//
-void SymbolTable::insertEntry(const std::string& Name, Type* T) {
+void SymbolTable::insertEntry(const std::string& Name, const Type* T) {
// Check to see if there is a naming conflict. If so, rename this type!
std::string UniqueName = Name;
@@ -261,7 +259,6 @@
// 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() );
@@ -318,7 +315,7 @@
}
for (type_iterator TI = tmap.begin(); TI != tmap.end(); ) {
- Type* T = (TI++)->second;
+ const Type* T = (TI++)->second;
remove(T);
RemovedSymbol = true;
}
@@ -483,7 +480,7 @@
for_each(P.second.begin(), P.second.end(), DumpVal);
}
-static void DumpTypes(const std::pair<const std::string, Type*>& T ) {
+static void DumpTypes(const std::pair<const std::string, const Type*>& T ) {
std::cerr << " '" << T.first << "' = ";
T.second->dump();
std::cerr << "\n";
More information about the llvm-commits
mailing list