From 3f4d118d73607a66ab0ce61438807ae710668d3c Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sat, 11 Aug 2018 10:43:40 +0100 Subject: [PATCH] microinstruction: Improve assert messages --- src/frontend/ir/microinstruction.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/frontend/ir/microinstruction.cpp b/src/frontend/ir/microinstruction.cpp index 3f80f5c1..906dc20c 100644 --- a/src/frontend/ir/microinstruction.cpp +++ b/src/frontend/ir/microinstruction.cpp @@ -6,6 +6,8 @@ #include +#include + #include "common/assert.h" #include "frontend/ir/microinstruction.h" #include "frontend/ir/opcodes.h" @@ -485,15 +487,15 @@ size_t Inst::NumArgs() const { } Value Inst::GetArg(size_t index) const { - ASSERT(index < GetNumArgsOf(op)); - ASSERT(!args[index].IsEmpty()); + ASSERT_MSG(index < GetNumArgsOf(op), "Inst::GetArg: index {} >= number of arguments of {} ({})", index, op, GetNumArgsOf(op)); + ASSERT_MSG(!args[index].IsEmpty(), "Inst::GetArg: index {} is empty", index); return args[index]; } void Inst::SetArg(size_t index, Value value) { - ASSERT(index < GetNumArgsOf(op)); - ASSERT(AreTypesCompatible(value.GetType(), GetArgTypeOf(op, index))); + ASSERT_MSG(index < GetNumArgsOf(op), "Inst::SetArg: index {} >= number of arguments of {} ({})", index, op, GetNumArgsOf(op)); + ASSERT_MSG(AreTypesCompatible(value.GetType(), GetArgTypeOf(op, index)), "Inst::SetArg: type {} of argument {} not compatible with operation {} ({})", value.GetType(), index, op, GetArgTypeOf(op, index)); if (!args[index].IsImmediate()) { UndoUse(args[index]);