[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Reid Spencer
reid at x10sys.com
Tue Jan 16 18:47:48 PST 2007
Changes in directory llvm/lib/AsmParser:
llvmAsmParser.y updated: 1.310 -> 1.311
---
Log message:
For PR1117: http://llvm.org/PR1117 :
Make the assembler generate a nice error message if a bad cast instruction
is attempted instead of asserting out. This is made possible by the
recently exposed method CastInst::castIsValid() which checks the validity
of any cast instruction.
---
Diffs of the changes: (+12 -15)
llvmAsmParser.y | 27 ++++++++++++---------------
1 files changed, 12 insertions(+), 15 deletions(-)
Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.310 llvm/lib/AsmParser/llvmAsmParser.y:1.311
--- llvm/lib/AsmParser/llvmAsmParser.y:1.310 Sun Jan 14 20:27:26 2007
+++ llvm/lib/AsmParser/llvmAsmParser.y Tue Jan 16 20:47:33 2007
@@ -1708,14 +1708,12 @@
if (!UpRefs.empty())
GEN_ERROR("Invalid upreference in type: " + (*$5)->getDescription());
Constant *Val = $3;
- const Type *Ty = $5->get();
- if (!Val->getType()->isFirstClassType())
- GEN_ERROR("cast constant expression from a non-primitive type: '" +
- Val->getType()->getDescription() + "'!");
- if (!Ty->isFirstClassType())
- GEN_ERROR("cast constant expression to a non-primitive type: '" +
- Ty->getDescription() + "'!");
- $$ = ConstantExpr::getCast($1, $3, $5->get());
+ const Type *DestTy = $5->get();
+ if (!CastInst::castIsValid($1, $3, DestTy))
+ GEN_ERROR("invalid cast opcode for cast from '" +
+ Val->getType()->getDescription() + "' to '" +
+ DestTy->getDescription() + "'!");
+ $$ = ConstantExpr::getCast($1, $3, DestTy);
delete $5;
}
| GETELEMENTPTR '(' ConstVal IndexList ')' {
@@ -2647,13 +2645,12 @@
if (!UpRefs.empty())
GEN_ERROR("Invalid upreference in type: " + (*$4)->getDescription());
Value* Val = $2;
- const Type* Ty = $4->get();
- if (!Val->getType()->isFirstClassType())
- GEN_ERROR("cast from a non-primitive type: '" +
- Val->getType()->getDescription() + "'!");
- if (!Ty->isFirstClassType())
- GEN_ERROR("cast to a non-primitive type: '" + Ty->getDescription() +"'!");
- $$ = CastInst::create($1, Val, $4->get());
+ const Type* DestTy = $4->get();
+ if (!CastInst::castIsValid($1, Val, DestTy))
+ GEN_ERROR("invalid cast opcode for cast from '" +
+ Val->getType()->getDescription() + "' to '" +
+ DestTy->getDescription() + "'!");
+ $$ = CastInst::create($1, Val, DestTy);
delete $4;
}
| SELECT ResolvedVal ',' ResolvedVal ',' ResolvedVal {
More information about the llvm-commits
mailing list