Skip to content

Commit 17d00de

Browse files
committed
ir: Handle default template parameters in libclang >3.9.
Fixes rust-lang#585
1 parent 31e4409 commit 17d00de

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/ir/template.rs

+16-5
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,22 @@ impl TemplateInstantiation {
233233

234234
let template_args = ty.template_args()
235235
.map_or(vec![], |args| {
236-
args.filter(|t| t.kind() != CXType_Invalid)
237-
.map(|t| {
238-
Item::from_ty_or_ref(t, t.declaration(), None, ctx)
239-
})
240-
.collect()
236+
match ty.canonical_type().template_args() {
237+
Some(canonical_args) => {
238+
let arg_count = args.len();
239+
args.chain(canonical_args.skip(arg_count))
240+
.filter(|t| t.kind() != CXType_Invalid)
241+
.map(|t| {
242+
Item::from_ty_or_ref(t, t.declaration(), None, ctx)
243+
}).collect()
244+
}
245+
None => {
246+
args.filter(|t| t.kind() != CXType_Invalid)
247+
.map(|t| {
248+
Item::from_ty_or_ref(t, t.declaration(), None, ctx)
249+
}).collect()
250+
}
251+
}
241252
});
242253

243254
let definition = ty.declaration()

0 commit comments

Comments
 (0)