Skip to content

Commit bb40ec3

Browse files
authored
Assert when Rust side of rule is missing (#88)
1 parent d15662f commit bb40ec3

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

cpp2rust/converter/translation_rule.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,18 @@ void LoadIrSrc(ExprRules &exprs, TypeRules &types,
189189
auto val = entry_val.getAsString();
190190
if (name[0] == 'f') {
191191
auto it = exprs.find(name);
192-
if (it != exprs.end()) {
193-
it->second.src = val->str();
192+
if (it == exprs.end()) {
193+
llvm::errs() << name << '\n';
194+
assert(0 && "ir_src.json expr entry has no matching IR target rule");
194195
}
196+
it->second.src = val->str();
195197
} else if (name[0] == 't') {
196198
auto it = types.find(name);
197-
if (it != types.end()) {
198-
it->second.src = val->str();
199+
if (it == types.end()) {
200+
llvm::errs() << name << '\n';
201+
assert(0 && "ir_src.json type entry has no matching IR target rule");
199202
}
203+
it->second.src = val->str();
200204
}
201205
}
202206
}

0 commit comments

Comments
 (0)