Support fully general case expressions, patch by Sanghyeon Seo!

llvm-svn: 44453
This commit is contained in:
Chris Lattner 2007-11-30 17:44:57 +00:00
parent 4e8c071612
commit aa0b570dfb
2 changed files with 5 additions and 1 deletions

View File

@ -444,7 +444,9 @@ void CodeGenFunction::EmitCaseStmt(const CaseStmt &S) {
StartBlock("sw.bb");
llvm::BasicBlock *CaseDest = Builder.GetInsertBlock();
llvm::ConstantInt *LV = cast<llvm::ConstantInt>(EmitScalarExpr(S.getLHS()));
llvm::APSInt CaseVal(32);
S.getLHS()->isIntegerConstantExpr(CaseVal, getContext());
llvm::ConstantInt *LV = llvm::ConstantInt::get(CaseVal);
SwitchInsn->addCase(LV, CaseDest);
EmitStmt(S.getSubStmt());
}

View File

@ -3,6 +3,8 @@
int foo(int i) {
int j = 0;
switch (i) {
case -1:
j = 1; break;
case 1 :
j = 2; break;
case 2: