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");
|
StartBlock("sw.bb");
|
||||||
llvm::BasicBlock *CaseDest = Builder.GetInsertBlock();
|
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);
|
SwitchInsn->addCase(LV, CaseDest);
|
||||||
EmitStmt(S.getSubStmt());
|
EmitStmt(S.getSubStmt());
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
int foo(int i) {
|
int foo(int i) {
|
||||||
int j = 0;
|
int j = 0;
|
||||||
switch (i) {
|
switch (i) {
|
||||||
|
case -1:
|
||||||
|
j = 1; break;
|
||||||
case 1 :
|
case 1 :
|
||||||
j = 2; break;
|
j = 2; break;
|
||||||
case 2:
|
case 2:
|
||||||
|
|
Loading…
Reference in New Issue