Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cpp2rust/converter/rules/rules_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ class RuleUsageCollector
AddKey(TypeKey(type));
if (const auto *alias =
llvm::dyn_cast<clang::TypedefType>(type.getTypePtr())) {
AddKey(DeclKey(alias->getDecl()));
if (const auto *record = llvm::dyn_cast<clang::RecordDecl>(
alias->getDecl()->getDeclContext())) {
AddKey(ClassKey(record));
Expand Down
12 changes: 9 additions & 3 deletions cpp2rust/rule_preprocessing/cpp_rule_indexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,18 @@ std::string ExprKey(clang::ASTContext &ctx, const clang::Decl *rule) {

std::string TypeKey(const clang::TypedefNameDecl *rule) {
auto type = rule->getUnderlyingType();
for (auto pointee = type;; pointee = pointee->getPointeeType()) {
if (auto alias = pointee->getAs<clang::TypedefType>();
alias && !pointee->isDependentType()) {
return RulesLoader::DeclKey(alias->getDecl());
}
if (!pointee->isPointerType() && !pointee->isReferenceType()) {
break;
}
}
if (auto key = RulesLoader::TypeKey(type); !key.empty()) {
return key;
}
if (!type->isDependentType() && type->getAs<clang::TypedefType>()) {
return RulesLoader::TypeKey(type);
}
while (type->isPointerType() || type->isReferenceType()) {
type = type->getPointeeType();
}
Expand Down
Loading