mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-04 05:31:51 +00:00
Merge SymbolTable::removeEntry into SymbolTable::remove, its only caller
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20483 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
58b004c2a3
commit
e4c872a8fa
@ -84,23 +84,13 @@ Value *SymbolTable::lookup(const Type *Ty, const std::string &Name) const {
|
|||||||
|
|
||||||
|
|
||||||
// lookup a type by name - returns null on failure
|
// lookup a type by name - returns null on failure
|
||||||
Type* SymbolTable::lookupType( const std::string& Name ) const {
|
Type* SymbolTable::lookupType(const std::string& Name) const {
|
||||||
type_const_iterator TI = tmap.find( Name );
|
type_const_iterator TI = tmap.find(Name);
|
||||||
if ( TI != tmap.end() )
|
if (TI != tmap.end())
|
||||||
return const_cast<Type*>(TI->second);
|
return const_cast<Type*>(TI->second);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove a value
|
|
||||||
void SymbolTable::remove(Value *N) {
|
|
||||||
assert(N->hasName() && "Value doesn't have name!");
|
|
||||||
|
|
||||||
plane_iterator PI = pmap.find(N->getType());
|
|
||||||
assert(PI != pmap.end() &&
|
|
||||||
"Trying to remove a value that doesn't have a type plane yet!");
|
|
||||||
removeEntry(PI, PI->second.find(N->getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// changeName - Given a value with a non-empty name, remove its existing entry
|
/// changeName - Given a value with a non-empty name, remove its existing entry
|
||||||
/// from the symbol table and insert a new one for Name. This is equivalent to
|
/// from the symbol table and insert a new one for Name. This is equivalent to
|
||||||
/// doing "remove(V), V->Name = Name, insert(V)", but is faster, and will not
|
/// doing "remove(V), V->Name = Name, insert(V)", but is faster, and will not
|
||||||
@ -133,42 +123,45 @@ void SymbolTable::changeName(Value *V, const std::string &name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove a value
|
||||||
|
void SymbolTable::remove(Value *N) {
|
||||||
|
assert(N->hasName() && "Value doesn't have name!");
|
||||||
|
|
||||||
// removeEntry - Remove a value from the symbol table...
|
plane_iterator PI = pmap.find(N->getType());
|
||||||
Value *SymbolTable::removeEntry(plane_iterator Plane, value_iterator Entry) {
|
assert(PI != pmap.end() &&
|
||||||
assert(Plane != pmap.end() &&
|
"Trying to remove a value that doesn't have a type plane yet!");
|
||||||
Entry != Plane->second.end() && "Invalid entry to remove!");
|
ValueMap &VM = PI->second;
|
||||||
|
value_iterator Entry = VM.find(N->getName());
|
||||||
|
assert(Entry != VM.end() && "Invalid entry to remove!");
|
||||||
|
|
||||||
Value *Result = Entry->second;
|
|
||||||
#if DEBUG_SYMBOL_TABLE
|
#if DEBUG_SYMBOL_TABLE
|
||||||
dump();
|
dump();
|
||||||
std::cerr << " Removing Value: " << Result->getName() << "\n";
|
std::cerr << " Removing Value: " << Entry->second->getName() << "\n";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Remove the value from the plane...
|
// Remove the value from the plane...
|
||||||
Plane->second.erase(Entry);
|
VM.erase(Entry);
|
||||||
|
|
||||||
// If the plane is empty, remove it now!
|
// If the plane is empty, remove it now!
|
||||||
if (Plane->second.empty()) {
|
if (VM.empty()) {
|
||||||
// If the plane represented an abstract type that we were interested in,
|
// If the plane represented an abstract type that we were interested in,
|
||||||
// unlink ourselves from this plane.
|
// unlink ourselves from this plane.
|
||||||
//
|
//
|
||||||
if (Plane->first->isAbstract()) {
|
if (N->getType()->isAbstract()) {
|
||||||
#if DEBUG_ABSTYPE
|
#if DEBUG_ABSTYPE
|
||||||
std::cerr << "Plane Empty: Removing type: "
|
std::cerr << "Plane Empty: Removing type: "
|
||||||
<< Plane->first->getDescription() << "\n";
|
<< N->getType()->getDescription() << "\n";
|
||||||
#endif
|
#endif
|
||||||
cast<DerivedType>(Plane->first)->removeAbstractTypeUser(this);
|
cast<DerivedType>(N->getType())->removeAbstractTypeUser(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
pmap.erase(Plane);
|
pmap.erase(PI);
|
||||||
}
|
}
|
||||||
return Result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// removeEntry - Remove a type from the symbol table...
|
// remove - Remove a type from the symbol table...
|
||||||
Type* SymbolTable::remove(type_iterator Entry) {
|
Type* SymbolTable::remove(type_iterator Entry) {
|
||||||
assert( Entry != tmap.end() && "Invalid entry to remove!");
|
assert(Entry != tmap.end() && "Invalid entry to remove!");
|
||||||
|
|
||||||
const Type* Result = Entry->second;
|
const Type* Result = Entry->second;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user