Use -Wl,-x instead of -s: it is more portable, and in particular,
[oota-llvm.git] / lib / VMCore / Function.cpp
index 5edd9ae2a6913e77218aa573327fbc92ae8b752a..70569c0f67ce7539f0e878921347b0fd5260ee95 100644 (file)
@@ -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) {
@@ -84,7 +84,7 @@ Function::Function(const FunctionType *Ty, bool isInternal,
   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
@@ -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);
 }