Skip to content

Commit 44a174e

Browse files
committed
Read the is_variadic attribute on the other side
1 parent 6e1a7cc commit 44a174e

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

cpp2rust/converter/converter.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,13 @@ bool Converter::VisitCallExpr(clang::CallExpr *expr) {
14471447
}
14481448

14491449
if (Mapper::Contains(expr->getCallee())) {
1450+
if (auto tgt_ir = Mapper::GetExprRule(GetCalleeOrExpr(expr))) {
1451+
if (tgt_ir->body.empty() && tgt_ir->is_variadic) {
1452+
ConvertGenericCallExpr(expr);
1453+
return false;
1454+
}
1455+
}
1456+
14501457
auto **args = expr->getArgs();
14511458
auto num_args = expr->getNumArgs();
14521459
auto ctx = CollectPrvalueToLRefArgs(expr);

cpp2rust/converter/translation_rule.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ ExprRule ParseExprRuleJSON(const llvm::json::Object &obj) {
104104
if (auto ms = obj.getBoolean("multi_statement"))
105105
ir.multi_statement = *ms;
106106

107+
if (auto v = obj.getBoolean("is_variadic"))
108+
ir.is_variadic = *v;
109+
107110
if (auto *generics = obj.getObject("generics")) {
108111
for (auto &[key, val] : *generics) {
109112
if (auto *arr = val.getAsArray()) {

cpp2rust/converter/translation_rule.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ struct ExprRule {
7070
std::vector<std::vector<std::string>> generics; // "T1" -> ["Ord", "Clone"]
7171
std::vector<BodyFragment> body;
7272
bool multi_statement = false;
73+
bool is_variadic = false;
7374

7475
void dump() const;
7576
void validate(const std::string &name) const;

0 commit comments

Comments
 (0)