X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FVMCore%2FFunction.cpp;h=3324565654b0f1bd32f61779874967e7ec5e4d9a;hb=27287de06b0a6d3c2713fc3a78281df8f5d1a0fa;hp=5edd9ae2a6913e77218aa573327fbc92ae8b752a;hpb=0dad6e9c95984804953db0fdcbe0c907d9ee351e;p=oota-llvm.git diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 5edd9ae2a69..3324565654b 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -57,11 +57,11 @@ Argument::Argument(const Type *Ty, const std::string &Name, Function *Par) // Specialize setName to take care of symbol table majik void Argument::setName(const std::string &name, SymbolTable *ST) { Function *P; - assert((ST == 0 || (!getParent() || ST == getParent()->getSymbolTable())) && + assert((ST == 0 || (!getParent() || ST == &getParent()->getSymbolTable())) && "Invalid symtab argument!"); - if ((P = getParent()) && hasName()) P->getSymbolTable()->remove(this); + if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this); Value::setName(name); - if (P && hasName()) P->getSymbolTableSure()->insert(this); + if (P && hasName()) P->getSymbolTable().insert(this); } void Argument::setParent(Function *parent) { @@ -77,14 +77,14 @@ void Argument::setParent(Function *parent) { // Function Implementation //===----------------------------------------------------------------------===// -Function::Function(const FunctionType *Ty, bool isInternal, +Function::Function(const FunctionType *Ty, LinkageTypes Linkage, const std::string &name, Module *ParentModule) - : GlobalValue(PointerType::get(Ty), Value::FunctionVal, isInternal, name) { + : GlobalValue(PointerType::get(Ty), Value::FunctionVal, Linkage, name) { BasicBlocks.setItemParent(this); BasicBlocks.setParent(this); ArgumentList.setItemParent(this); ArgumentList.setParent(this); - SymTab = 0; + SymTab = new SymbolTable(); // Create the arguments vector, all arguments start out unnamed. for (unsigned i = 0, e = Ty->getNumParams(); i != e; ++i) { @@ -114,11 +114,11 @@ Function::~Function() { // Specialize setName to take care of symbol table majik void Function::setName(const std::string &name, SymbolTable *ST) { Module *P; - assert((ST == 0 || (!getParent() || ST == getParent()->getSymbolTable())) && + assert((ST == 0 || (!getParent() || ST == &getParent()->getSymbolTable())) && "Invalid symtab argument!"); - if ((P = getParent()) && hasName()) P->getSymbolTable()->remove(this); + if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this); Value::setName(name); - if (P && getName() != "") P->getSymbolTableSure()->insert(this); + if (P && getName() != "") P->getSymbolTable().insert(this); } void Function::setParent(Module *parent) { @@ -137,27 +137,6 @@ const Type *Function::getReturnType() const { return getFunctionType()->getReturnType(); } -SymbolTable *Function::getSymbolTableSure() { - if (!SymTab) SymTab = new SymbolTable(); - return SymTab; -} - -// hasSymbolTable() - Returns true if there is a symbol table allocated to -// this object AND if there is at least one name in it! -// -bool Function::hasSymbolTable() const { - if (!SymTab) return false; - - for (SymbolTable::const_iterator I = SymTab->begin(); - I != SymTab->end(); ++I) { - if (I->second.begin() != I->second.end()) - return true; // Found nonempty type plane! - } - - return false; -} - - // dropAllReferences() - This function causes all the subinstructions to "let // go" of all references that they are maintaining. This allows one to // 'delete' a whole class at a time, even though there may be circular @@ -175,10 +154,10 @@ void Function::dropAllReferences() { // GlobalVariable Implementation //===----------------------------------------------------------------------===// -GlobalVariable::GlobalVariable(const Type *Ty, bool constant, bool isIntern, +GlobalVariable::GlobalVariable(const Type *Ty, bool constant, LinkageTypes Link, Constant *Initializer, const std::string &Name, Module *ParentModule) - : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, isIntern, Name), + : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, Link, Name), isConstantGlobal(constant) { if (Initializer) Operands.push_back(Use((Value*)Initializer, this)); @@ -199,9 +178,9 @@ void GlobalVariable::setParent(Module *parent) { // Specialize setName to take care of symbol table majik void GlobalVariable::setName(const std::string &name, SymbolTable *ST) { Module *P; - assert((ST == 0 || (!getParent() || ST == getParent()->getSymbolTable())) && + assert((ST == 0 || (!getParent() || ST == &getParent()->getSymbolTable())) && "Invalid symtab argument!"); - if ((P = getParent()) && hasName()) P->getSymbolTable()->remove(this); + if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this); Value::setName(name); - if (P && getName() != "") P->getSymbolTableSure()->insert(this); + if (P && getName() != "") P->getSymbolTable().insert(this); }