From c8546c7af133a246fa207cee63178c8c7904417b Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 14 Nov 2016 17:07:09 +0000 Subject: [PATCH] Handle non-inlined clang::Type::getAs specializations in extract_symbols.py The existing logic was to discard any symbols representing function template instantiations, as the definitions were assumed to be inline. But there are three explicit specializations of clang::Type::getAs that are only defined in Clang's lib/AST/Type.cpp, and at least the plugin used by the LibreOffice build (https://wiki.documentfoundation.org/Development/Clang_plugins) uses those functions. Differential Revision: https://reviews.llvm.org/D26455 llvm-svn: 286841 --- utils/extract_symbols.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/utils/extract_symbols.py b/utils/extract_symbols.py index 9f467a7d055..96ae24c608e 100755 --- a/utils/extract_symbols.py +++ b/utils/extract_symbols.py @@ -128,8 +128,12 @@ def should_keep_microsoft_symbol(symbol, calling_convention_decoration): if match: return match.group(1) return symbol - # Function template instantiations start with ?$, discard them as it's - # assumed that the definition is public + # Function template instantiations start with ?$; keep the instantiations of + # clang::Type::getAs, as some of them are explipict specializations that are + # defined in clang's lib/AST/Type.cpp; discard the rest as it's assumed that + # the definition is public + elif re.match('\?\?\$getAs@.+@Type@clang@@', symbol): + return symbol elif symbol.startswith('??$'): return None # Deleting destructors start with ?_G or ?_E and can be discarded because @@ -195,8 +199,12 @@ def should_keep_itanium_symbol(symbol, calling_convention_decoration): # defined in headers and not required to be kept if re.match('[CD][123]', names[-1][0]) and names[-2][1]: return None - # Discard function template instantiations as it's assumed that the - # definition is public + # Keep the instantiations of clang::Type::getAs, as some of them are + # explipict specializations that are defined in clang's lib/AST/Type.cpp; + # discard any other function template instantiations as it's assumed that + # the definition is public + elif symbol.startswith('_ZNK5clang4Type5getAs'): + return symbol elif names[-1][1]: return None # Keep llvm:: and clang:: names