From f1fc25387ef3d163ffa372f0d60843f4dad08975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20M=C3=BCller?= Date: Wed, 12 Apr 2017 17:56:35 +0200 Subject: [PATCH] Fix USR collision with SFINAE in return type --- src/libclang/parse_functions.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libclang/parse_functions.cpp b/src/libclang/parse_functions.cpp index 699e22e..f42f110 100644 --- a/src/libclang/parse_functions.cpp +++ b/src/libclang/parse_functions.cpp @@ -15,7 +15,16 @@ cpp_entity_id detail::get_entity_id(const CXCursor& cur) { cxstring usr(clang_getCursorUSR(cur)); DEBUG_ASSERT(!usr.empty(), detail::parse_error_handler{}, cur, "cannot create id for entity"); - return cpp_entity_id(usr.c_str()); + if (clang_getCursorKind(cur) == CXCursor_FunctionTemplate) + { + // we have a function template + // combine return type with USR to ensure no ambiguity when SFINAE is applied there + // (and hope this prevents all collisions...) + cxstring type_spelling(clang_getTypeSpelling(clang_getCursorResultType(cur))); + return cpp_entity_id(std::string(usr.c_str()) + type_spelling.c_str()); + } + else + return cpp_entity_id(usr.c_str()); } detail::cxstring detail::get_cursor_name(const CXCursor& cur)