forked from OSchip/llvm-project
Support fully general case expressions, patch by Sanghyeon Seo!
llvm-svn: 44453
This commit is contained in:
parent
4e8c071612
commit
aa0b570dfb
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue