diff --git a/BitcodeEmitter.cpp b/BitcodeEmitter.cpp index b468ae2..7b0d309 100644 --- a/BitcodeEmitter.cpp +++ b/BitcodeEmitter.cpp @@ -460,6 +460,7 @@ bool BitcodeEmitter::emit(Branch const& node) { getGlobalContext(), "endif" ); + assert(!body.getCases().empty()); BranchCase const& last = body.getCases().back(); for (BranchCase const& cas: body.getCases()) { diff --git a/CppEmitter.cpp b/CppEmitter.cpp index b708874..24de662 100644 --- a/CppEmitter.cpp +++ b/CppEmitter.cpp @@ -201,7 +201,7 @@ bool CppEmitter::emit(Branch const& branch) { stream << "if ("; GUARDED(var.emit(this)); - if (body.getCases().size() > 0) { + if (!body.getCases().empty()) { BranchCase const& last = body.getCases().back(); for (BranchCase const& cas: body.getCases()) { emitBranchCase(cas); @@ -236,6 +236,8 @@ bool CppEmitter::emit(Assignment const& assignment) { bool CppEmitter::emitFunctionArglist(PointerList const& args) { + if (args.empty()) return stream; + Expression const& last = args.back(); for (Expression const& arg: args) { GUARDED(arg.emit(this)); @@ -297,8 +299,9 @@ std::ostream& operator<<(std::ostream &stream, Type const& type) { } bool CppEmitter::emitFunctionParams(PointerList const& funargs) { - FunArg const& last = funargs.back(); + if (funargs.empty()) return stream; + FunArg const& last = funargs.back(); for (FunArg const& funarg: funargs) { stream << funarg.getType() << (funarg.isPointer()? "* ": " "); GUARDED(funarg.getName().emit(this));