Skip to content

Commit 7b1808b

Browse files
committed
work
1 parent 3f30d90 commit 7b1808b

5 files changed

Lines changed: 33 additions & 0 deletions

File tree

‎cpp2rust/converter/converter.cpp‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,15 @@ bool Converter::VisitNamespaceDecl(clang::NamespaceDecl *decl) {
12261226
return false;
12271227
}
12281228

1229+
bool Converter::VisitLinkageSpecDecl(clang::LinkageSpecDecl *decl) {
1230+
for (auto *child : decl->decls()) {
1231+
if (IsInMainFile(child) || !decl_ids_.contains(GetID(child))) {
1232+
Convert(child);
1233+
}
1234+
}
1235+
return false;
1236+
}
1237+
12291238
bool Converter::VisitTypedefDecl([[maybe_unused]] clang::TypedefDecl *decl) {
12301239
return false;
12311240
}

‎cpp2rust/converter/converter.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
173173

174174
virtual bool VisitNamespaceDecl(clang::NamespaceDecl *decl);
175175

176+
bool VisitLinkageSpecDecl(clang::LinkageSpecDecl *decl);
177+
176178
virtual bool VisitTypedefDecl(clang::TypedefDecl *decl);
177179
virtual bool VisitTypeAliasDecl(clang::TypeAliasDecl *decl);
178180
virtual bool VisitTypeAliasTemplateDecl(clang::TypeAliasTemplateDecl *decl);
@@ -488,6 +490,11 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
488490

489491
virtual bool VisitClassTemplateDecl(clang::ClassTemplateDecl *decl);
490492

493+
bool TraverseClassTemplateSpecializationDecl(
494+
clang::ClassTemplateSpecializationDecl *) {
495+
return true;
496+
}
497+
491498
virtual bool
492499
VisitCXXStdInitializerListExpr(clang::CXXStdInitializerListExpr *expr);
493500

‎tests/multi-file/out_of_line_methods_cross_tu/a.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,9 @@ int main() {
1212
Derived derived(3);
1313
Base *base = &derived;
1414
assert(base->apply(5) == 15);
15+
16+
Pair pair{7, 3};
17+
assert(pair_sum(&pair) == 10);
18+
assert(pair_diff(&pair) == 4);
1519
return 0;
1620
}

‎tests/multi-file/out_of_line_methods_cross_tu/b.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ int S::add(int x) {
1414
Derived::Derived(int factor) : factor(factor) {}
1515

1616
int Derived::apply(int x) { return factor * x; }
17+
18+
int pair_sum(const struct Pair *p) { return p->first + p->second; }

‎tests/multi-file/out_of_line_methods_cross_tu/s.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,14 @@ class Derived : public Base {
2626

2727
int factor;
2828
};
29+
30+
extern "C" {
31+
struct Pair {
32+
int first;
33+
int second;
34+
};
35+
36+
int pair_sum(const struct Pair *p);
37+
38+
inline int pair_diff(const struct Pair *p) { return p->first - p->second; }
39+
}

0 commit comments

Comments
 (0)