From 1e50e127424f515cbfb76c73ebceb9d78cb9a167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20M=C3=BCller?= Date: Tue, 9 Jan 2018 21:03:00 +0100 Subject: [PATCH] Fix get_instantiation_template() so that it returns the primary template --- src/libclang/type_parser.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libclang/type_parser.cpp b/src/libclang/type_parser.cpp index 61abb86..63e969b 100644 --- a/src/libclang/type_parser.cpp +++ b/src/libclang/type_parser.cpp @@ -445,7 +445,14 @@ namespace auto decl = clang_getTypeDeclaration(type); auto count = clang_Type_getNumTemplateArguments(clang_getCursorType(decl)); if (count > 0 || is_direct_templated(decl)) - return decl; + { + auto specialized = clang_getSpecializedCursorTemplate(decl); + if (clang_Cursor_isNull(specialized)) + // is already a template + return decl; + else + return specialized; + } else { // look if the templ_name matches a template template parameter