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/Function.h"
10 #include "llvm/SymbolTable.h"
12 Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name)
13 : User(ty, Value::InstructionVal, Name) {
18 // Specialize setName to take care of symbol table majik
19 void Instruction::setName(const std::string &name, SymbolTable *ST) {
20 BasicBlock *P = 0; Function *PP = 0;
21 assert((ST == 0 || !getParent() || !getParent()->getParent() ||
22 ST == getParent()->getParent()->getSymbolTable()) &&
23 "Invalid symtab argument!");
24 if ((P = getParent()) && (PP = P->getParent()) && hasName())
25 PP->getSymbolTable()->remove(this);
27 if (PP && hasName()) PP->getSymbolTableSure()->insert(this);