Skip to content

Commit 0ec7b78

Browse files
authored
Merge pull request #1423 from google/fix-concrete-typedef-dep
Fix concrete typedef dep
2 parents 597d6de + d770c8b commit 0ec7b78

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

engine/src/conversion/analysis/type_converter.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,10 @@ impl<'a> TypeConverter<'a> {
372372
}
373373
let (new_tn, api) = self.get_templated_typename(&Type::Path(typ))?;
374374
extra_apis.extend(api.into_iter());
375-
deps.remove(&tn);
375+
// Although it's tempting to remove the dep on the original type,
376+
// this means we wouldn't spot cases where the original type can't
377+
// be represented in C++, e.g. because it has an unused template parameter.
378+
// So we keep the original dep too.
376379
typ = new_tn.to_type_path();
377380
deps.insert(new_tn);
378381
}

engine/src/conversion/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<'a> BridgeConverter<'a> {
120120
Self::dump_apis("parsing", &apis);
121121
// Inside parse_results, we now have a list of APIs.
122122
// We now enter various analysis phases.
123-
// Next, convert any typedefs.
123+
// First, convert any typedefs.
124124
// "Convert" means replacing bindgen-style type targets
125125
// (e.g. root::std::unique_ptr) with cxx-style targets (e.g. UniquePtr).
126126
let apis = convert_typedef_targets(self.config, apis);

integration-tests/tests/integration_test.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12403,6 +12403,33 @@ fn test_override_typedef_fn() {
1240312403
run_test("", hdr, quote! {}, &["Foo"], &[]);
1240412404
}
1240512405

12406+
#[test]
12407+
fn test_double_template_w_default() {
12408+
let hdr = indoc! {"
12409+
class Widget {};
12410+
12411+
template <class T>
12412+
class RefPtr {
12413+
private:
12414+
T* m_ptr;
12415+
};
12416+
12417+
class FakeAlloc {};
12418+
12419+
template <typename T, typename A=FakeAlloc>
12420+
class Holder {
12421+
A alloc;
12422+
};
12423+
12424+
typedef Holder<RefPtr<Widget>> WidgetRefHolder;
12425+
class Problem {
12426+
public:
12427+
WidgetRefHolder& getWidgets();
12428+
};
12429+
"};
12430+
run_test("", hdr, quote! {}, &["Problem"], &[]);
12431+
}
12432+
1240612433
// Yet to test:
1240712434
// - Ifdef
1240812435
// - Out param pointers

0 commit comments

Comments
 (0)