summaryrefslogtreecommitdiff
path: root/lib/Bytecode
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-10-01 20:11:19 +0000
committerChris Lattner <sabre@nondot.org>2001-10-01 20:11:19 +0000
commit1d87bcf4909b06dcd86320722653341f08b8b396 (patch)
treec96a6176090b950f14ac44061b68f243a1920fe3 /lib/Bytecode
parentcfe26c930ae691ff3012736555846c45087e1a9e (diff)
downloadllvm-1d87bcf4909b06dcd86320722653341f08b8b396.tar.gz
llvm-1d87bcf4909b06dcd86320722653341f08b8b396.tar.bz2
llvm-1d87bcf4909b06dcd86320722653341f08b8b396.tar.xz
Convert more code to use new style casts
Eliminate old style casts from value.h git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@696 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode')
-rw-r--r--lib/Bytecode/Reader/ConstantReader.cpp8
-rw-r--r--lib/Bytecode/Reader/InstructionReader.cpp28
-rw-r--r--lib/Bytecode/Reader/Reader.cpp6
-rw-r--r--lib/Bytecode/Reader/ReaderInternals.h3
-rw-r--r--lib/Bytecode/Writer/SlotCalculator.cpp4
-rw-r--r--lib/Bytecode/Writer/Writer.cpp6
6 files changed, 27 insertions, 28 deletions
diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp
index 67cfff7b97..aaecedddfa 100644
--- a/lib/Bytecode/Reader/ConstantReader.cpp
+++ b/lib/Bytecode/Reader/ConstantReader.cpp
@@ -241,8 +241,8 @@ bool BytecodeParser::parseConstPoolValue(const uchar *&Buf,
unsigned Slot;
if (read_vbr(Buf, EndBuf, Slot)) return failure(true);
Value *V = getValue(AT->getElementType(), Slot, false);
- if (!V || !V->isConstant()) return failure(true);
- Elements.push_back((ConstPoolVal*)V);
+ if (!V || !isa<ConstPoolVal>(V)) return failure(true);
+ Elements.push_back(cast<ConstPoolVal>(V));
}
V = ConstPoolArray::get(AT, Elements);
break;
@@ -257,9 +257,9 @@ bool BytecodeParser::parseConstPoolValue(const uchar *&Buf,
unsigned Slot;
if (read_vbr(Buf, EndBuf, Slot)) return failure(true);
Value *V = getValue(ET[i], Slot, false);
- if (!V || !V->isConstant())
+ if (!V || !isa<ConstPoolVal>(V))
return failure(true);
- Elements.push_back((ConstPoolVal*)V);
+ Elements.push_back(cast<ConstPoolVal>(V));
}
V = ConstPoolStruct::get(ST, Elements);
diff --git a/lib/Bytecode/Reader/InstructionReader.cpp b/lib/Bytecode/Reader/InstructionReader.cpp
index 8c3e08ff94..300c40999e 100644
--- a/lib/Bytecode/Reader/InstructionReader.cpp
+++ b/lib/Bytecode/Reader/InstructionReader.cpp
@@ -266,25 +266,25 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
case 0: cerr << "Invalid load encountered!\n"; return failure(true);
case 1: break;
case 2: V = getValue(Type::UByteTy, Raw.Arg2);
- if (!V->isConstant()) return failure(true);
- Idx.push_back(V->castConstant());
+ if (!isa<ConstPoolVal>(V)) return failure(true);
+ Idx.push_back(cast<ConstPoolVal>(V));
break;
case 3: V = getValue(Type::UByteTy, Raw.Arg2);
- if (!V->isConstant()) return failure(true);
- Idx.push_back(V->castConstant());
+ if (!isa<ConstPoolVal>(V)) return failure(true);
+ Idx.push_back(cast<ConstPoolVal>(V));
V = getValue(Type::UByteTy, Raw.Arg3);
- if (!V->isConstant()) return failure(true);
- Idx.push_back(V->castConstant());
+ if (!isa<ConstPoolVal>(V)) return failure(true);
+ Idx.push_back(cast<ConstPoolVal>(V));
break;
default:
V = getValue(Type::UByteTy, Raw.Arg2);
- if (!V->isConstant()) return failure(true);
- Idx.push_back(V->castConstant());
+ if (!isa<ConstPoolVal>(V)) return failure(true);
+ Idx.push_back(cast<ConstPoolVal>(V));
vector<unsigned> &args = *Raw.VarArgs;
for (unsigned i = 0, E = args.size(); i != E; ++i) {
V = getValue(Type::UByteTy, args[i]);
- if (!V->isConstant()) return failure(true);
- Idx.push_back(V->castConstant());
+ if (!isa<ConstPoolVal>(V)) return failure(true);
+ Idx.push_back(cast<ConstPoolVal>(V));
}
delete Raw.VarArgs;
break;
@@ -304,15 +304,15 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
case 1: cerr << "Invalid store encountered!\n"; return failure(true);
case 2: break;
case 3: V = getValue(Type::UByteTy, Raw.Arg3);
- if (!V->isConstant()) return failure(true);
- Idx.push_back(V->castConstant());
+ if (!isa<ConstPoolVal>(V)) return failure(true);
+ Idx.push_back(cast<ConstPoolVal>(V));
break;
default:
vector<unsigned> &args = *Raw.VarArgs;
for (unsigned i = 0, E = args.size(); i != E; ++i) {
V = getValue(Type::UByteTy, args[i]);
- if (!V->isConstant()) return failure(true);
- Idx.push_back(V->castConstant());
+ if (!isa<ConstPoolVal>(V)) return failure(true);
+ Idx.push_back(cast<ConstPoolVal>(V));
}
delete Raw.VarArgs;
break;
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index b7904bb60f..0e4883034e 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -206,7 +206,7 @@ bool BytecodeParser::ParseSymbolTable(const uchar *&Buf, const uchar *EndBuf,
return failure(true);
}
BCR_TRACE(4, "Map: '" << Name << "' to #" << slot << ":" << D;
- if (!D->isInstruction()) cerr << endl);
+ if (!isa<Instruction>(D)) cerr << endl);
D->setName(Name, ST);
}
@@ -291,7 +291,7 @@ bool BytecodeParser::ParseMethod(const uchar *&Buf, const uchar *EndBuf,
Value *MethPHolder = getValue(MTy, MethSlot, false);
assert(MethPHolder && "Something is broken no placeholder found!");
- assert(MethPHolder->isMethod() && "Not a method?");
+ assert(isa<Method>(MethPHolder) && "Not a method?");
unsigned type; // Type slot
assert(!getTypeSlot(MTy, type) && "How can meth type not exist?");
@@ -359,7 +359,7 @@ bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End,
if (read_vbr(Buf, End, MethSignature)) return failure(true);
while (MethSignature != Type::VoidTyID) { // List is terminated by Void
const Type *Ty = getType(MethSignature);
- if (!Ty || !Ty->isMethodType()) {
+ if (!Ty || !isa<MethodType>(Ty)) {
cerr << "Method not meth type! Ty = " << Ty << endl;
return failure(true);
}
diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h
index ed4f1a4bba..cf5a43ef3b 100644
--- a/lib/Bytecode/Reader/ReaderInternals.h
+++ b/lib/Bytecode/Reader/ReaderInternals.h
@@ -129,8 +129,7 @@ struct BBPlaceHolderHelper : public BasicBlock {
struct MethPlaceHolderHelper : public Method {
MethPlaceHolderHelper(const Type *Ty)
- : Method((const MethodType*)Ty) {
- assert(Ty->isMethodType() && "Method placeholders must be method types!");
+ : Method(cast<const MethodType>(Ty)) {
}
};
diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp
index d0f37fb723..38980e5e63 100644
--- a/lib/Bytecode/Writer/SlotCalculator.cpp
+++ b/lib/Bytecode/Writer/SlotCalculator.cpp
@@ -106,7 +106,7 @@ void SlotCalculator::processSymbolTableConstants(const SymbolTable *ST) {
for (SymbolTable::const_iterator I = ST->begin(), E = ST->end(); I != E; ++I)
for (SymbolTable::type_const_iterator TI = I->second.begin(),
TE = I->second.end(); TI != TE; ++TI)
- if (TI->second->isConstant())
+ if (isa<ConstPoolVal>(TI->second))
insertValue(TI->second);
}
@@ -223,7 +223,7 @@ int SlotCalculator::getValSlot(const Value *D) const {
int SlotCalculator::insertValue(const Value *D) {
- if (D->isConstant() || D->isGlobal()) {
+ if (isa<ConstPoolVal>(D) || isa<GlobalVariable>(D)) {
const User *U = (const User *)D;
// This makes sure that if a constant has uses (for example an array
// of const ints), that they are inserted also. Same for global variable
diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp
index 94cbcec328..5df2fdabde 100644
--- a/lib/Bytecode/Writer/Writer.cpp
+++ b/lib/Bytecode/Writer/Writer.cpp
@@ -79,7 +79,7 @@ void BytecodeWriter::outputConstants(bool isMethod) {
ValNo = Type::FirstDerivedTyID; // Start emitting at the derived types...
// Scan through and ignore method arguments...
- for (; ValNo < Plane.size() && Plane[ValNo]->isMethodArgument(); ValNo++)
+ for (; ValNo < Plane.size() && isa<MethodArgument>(Plane[ValNo]); ValNo++)
/*empty*/;
unsigned NC = ValNo; // Number of constants
@@ -103,7 +103,7 @@ void BytecodeWriter::outputConstants(bool isMethod) {
for (unsigned i = ValNo; i < ValNo+NC; ++i) {
const Value *V = Plane[i];
- if (const ConstPoolVal *CPV = V->castConstant()) {
+ if (const ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(V)) {
//cerr << "Serializing value: <" << V->getType() << ">: "
// << ((const ConstPoolVal*)V)->getStrValue() << ":"
// << Out.size() << "\n";
@@ -127,7 +127,7 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
// Fields: bit0 = isConstant, bit1 = hasInitializer, bit2+ = slot#
unsigned oSlot = ((unsigned)Slot << 2) | (GV->hasInitializer() << 1) |
- GV->isConstant();
+ isa<ConstPoolVal>(GV);
output_vbr(oSlot, Out);
// If we have an initialized, output it now.