Skip to content

Commit fe710dd

Browse files
committed
Check for decayed array to pointer types irregardless of templates
1 parent 0a989ae commit fe710dd

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

cpp2rust/converter/translation_rule.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ class Callback : public clang::ast_matchers::MatchFinder::MatchCallback {
163163
type = var->getType();
164164
}
165165

166+
if (const auto *decayed = type->getAs<clang::DecayedType>()) {
167+
clang::QualType original = decayed->getOriginalType();
168+
if (original->isArrayType()) {
169+
type = original;
170+
}
171+
}
172+
166173
add(Mapper::ToString(type));
167174
return;
168175
}
@@ -716,15 +723,7 @@ class Callback : public clang::ast_matchers::MatchFinder::MatchCallback {
716723
clang::Sema::ContextRAII savedContext(*sema_, ns);
717724
clang::FunctionDecl *rule = instantiateRuleDecl(decl);
718725
assert(rule && "Rule resolution failed");
719-
720-
clang::QualType type = rule->getParamDecl(0)->getType();
721-
if (const auto *decayed = type->getAs<clang::DecayedType>()) {
722-
clang::QualType original = decayed->getOriginalType();
723-
if (original->isArrayType()) {
724-
return original;
725-
}
726-
}
727-
return type;
726+
return rule->getParamDecl(0)->getType();
728727
}
729728
};
730729

0 commit comments

Comments
 (0)