diff options
author | Chris Lattner <sabre@nondot.org> | 2002-07-30 18:54:25 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-07-30 18:54:25 +0000 |
commit | 3cd8c56cbb57f2e15298e38d51705212a9f44527 (patch) | |
tree | 6fdacb20c2afed8cbf3bad518e99b334ba7810f4 /llvm/lib/Bytecode/Writer | |
parent | a13a2dac7eebbbe5e9c31966329a208201e6cb3c (diff) | |
download | bcm5719-llvm-3cd8c56cbb57f2e15298e38d51705212a9f44527.tar.gz bcm5719-llvm-3cd8c56cbb57f2e15298e38d51705212a9f44527.zip |
Cleanup ConstantExpr handling:
* Correctly delete TypeHandles in AsmParser. In addition to not leaking
memory, this prevents a bug that could have occurred when a type got
resolved that the constexpr was using
* Check for errors in the AsmParser instead of hitting assertion failures
deep in the code
* Simplify the interface to the ConstantExpr class, removing unneccesary
parameters to the ::get* methods.
* Rename the 'getelementptr' version of ConstantExpr::get to
ConstantExpr::getGetElementPtr
llvm-svn: 3161
Diffstat (limited to 'llvm/lib/Bytecode/Writer')
-rw-r--r-- | llvm/lib/Bytecode/Writer/ConstantWriter.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Bytecode/Writer/ConstantWriter.cpp b/llvm/lib/Bytecode/Writer/ConstantWriter.cpp index 2091cedba39..5e24018f113 100644 --- a/llvm/lib/Bytecode/Writer/ConstantWriter.cpp +++ b/llvm/lib/Bytecode/Writer/ConstantWriter.cpp @@ -100,7 +100,8 @@ bool BytecodeWriter::outputConstant(const Constant *CPV) { // We must check for a ConstantExpr before switching by type because // a ConstantExpr can be of any type, and has no explicit value. // - if (const ConstantExpr* CE = dyn_cast<ConstantExpr>(CPV)) { + if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CPV)) { + // FIXME: Encoding of constant exprs could be much more compact! assert(CE->getNumOperands() > 0 && "ConstantExpr with 0 operands"); output_vbr(CE->getNumOperands(), Out); // flags as an expr output_vbr(CE->getOpcode(), Out); // flags as an expr @@ -113,9 +114,9 @@ bool BytecodeWriter::outputConstant(const Constant *CPV) { output_vbr((unsigned)Slot, Out); } return false; - } - else + } else { output_vbr((unsigned)0, Out); // flag as not a ConstantExpr + } switch (CPV->getType()->getPrimitiveID()) { case Type::BoolTyID: // Boolean Types |