1 //===-- Instruction.cpp - Implement the Instruction class --------*- C++ -*--=//
3 // This file implements the Instruction class for the VMCore library.
5 //===----------------------------------------------------------------------===//
7 #include "llvm/Instruction.h"
8 #include "llvm/BasicBlock.h"
9 #include "llvm/Method.h"
10 #include "llvm/SymbolTable.h"
12 Instruction::Instruction(const Type *ty, unsigned it, const string &Name)
13 : User(ty, Value::InstructionVal, Name) {
18 Instruction::~Instruction() {
19 assert(getParent() == 0 && "Instruction still embeded in basic block!");
22 // Specialize setName to take care of symbol table majik
23 void Instruction::setName(const string &name) {
24 BasicBlock *P = 0; Method *PP = 0;
25 if ((P = getParent()) && (PP = P->getParent()) && hasName())
26 PP->getSymbolTable()->remove(this);
28 if (PP && hasName()) PP->getSymbolTableSure()->insert(this);