diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-27 14:46:29 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-27 14:46:29 -0800 |
commit | 1702913f5f98d374ba822170d810ad2bb1afa78e (patch) | |
tree | 2f255055207c1d15ed194962f1f42e5fd920395e /lib/Target/CppBackend/CPPBackend.cpp | |
parent | 69800b7975f47bbeec3d7e592393ea88b7336470 (diff) |
fix switches
Diffstat (limited to 'lib/Target/CppBackend/CPPBackend.cpp')
-rw-r--r-- | lib/Target/CppBackend/CPPBackend.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index 7864a0131e..a64359de06 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -2072,16 +2072,21 @@ void CppWriter::printFunctionBody(const Function *F) { BasicBlock *DD = SI->getDefaultDest(); std::string P = getPhiCode(&*BI, DD); LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*DD], NULL, P.size() > 0 ? P.c_str() : NULL); + std::map<const BasicBlock*, std::string> BlocksToConditions; for (SwitchInst::ConstCaseIt i = SI->case_begin(), e = SI->case_end(); i != e; ++i) { const BasicBlock *BB = i.getCaseSuccessor(); const IntegersSubset CaseVal = i.getCaseValueEx(); assert(CaseVal.isSingleNumbersOnly()); std::string Condition = ""; for (unsigned Index = 0; Index < CaseVal.getNumItems(); Index++) { - Condition += "case " + utostr(*(CaseVal.getSingleNumber(Index).toConstantInt()->getValue().getRawData())) + ':'; + Condition += "case " + CaseVal.getSingleNumber(Index).toConstantInt()->getValue().toString(10, true) + ": "; } + BlocksToConditions[BB] = Condition + BlocksToConditions[BB]; + } + for (SwitchInst::ConstCaseIt i = SI->case_begin(), e = SI->case_end(); i != e; ++i) { + const BasicBlock *BB = i.getCaseSuccessor(); std::string P = getPhiCode(&*BI, BB); - LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*BB], Condition.c_str(), P.size() > 0 ? P.c_str() : NULL); + LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*BB], BlocksToConditions[BB].c_str(), P.size() > 0 ? P.c_str() : NULL); } break; } |