MEGAPATCH checkin.
[oota-llvm.git] / lib / VMCore / Instruction.cpp
1 //===-- Instruction.cpp - Implement the Instruction class --------*- C++ -*--=//
2 //
3 // This file implements the Instruction class for the VMCore library.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #include "llvm/Function.h"
8 #include "llvm/SymbolTable.h"
9 #include "llvm/Type.h"
10
11 Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name) 
12   : User(ty, Value::InstructionVal, Name) {
13   Parent = 0;
14   iType = it;
15 }
16
17 // Specialize setName to take care of symbol table majik
18 void Instruction::setName(const std::string &name, SymbolTable *ST) {
19   BasicBlock *P = 0; Function *PP = 0;
20   assert((ST == 0 || !getParent() || !getParent()->getParent() || 
21           ST == getParent()->getParent()->getSymbolTable()) &&
22          "Invalid symtab argument!");
23   if ((P = getParent()) && (PP = P->getParent()) && hasName())
24     PP->getSymbolTable()->remove(this);
25   Value::setName(name);
26   if (PP && hasName()) PP->getSymbolTableSure()->insert(this);
27 }