From ae3dc53325b4d5cc54b72c8499b4dd427244f018 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Wed, 24 Apr 2024 13:35:04 -0400 Subject: [PATCH] Generating VTT symbols for public virtual base classes --- src/server/symbols.map | 9 +++++---- tools/symbols_map_generator/main.py | 27 ++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/server/symbols.map b/src/server/symbols.map index 0939336b26d..bce438e3082 100644 --- a/src/server/symbols.map +++ b/src/server/symbols.map @@ -1,10 +1,11 @@ MIR_SERVER_INTERNAL_2.17 { global: extern "C++" { - VTT?for?mir::DefaultServerConfiguration; - VTT?for?mir::scene::ApplicationNotRespondingDetectorWrapper; - VTT?for?mir::shell::ShellWrapper; - VTT?for?mir::shell::SystemCompositorWindowManager; + VTT?for?mir::DefaultServerConfiguration + VTT?for?mir::DefaultServerStatusListener + VTT?for?mir::shell::AbstractShell + VTT?for?mir::shell::Shell + VTT?for?mir::shell::ShellWrapper mir::BasicCallback::BasicCallback*; mir::BasicCallback::lock*; mir::BasicCallback::operator*; diff --git a/tools/symbols_map_generator/main.py b/tools/symbols_map_generator/main.py index d5b8a88f36d..d81cc57bfd8 100755 --- a/tools/symbols_map_generator/main.py +++ b/tools/symbols_map_generator/main.py @@ -104,6 +104,29 @@ def has_vtable(node: clang.cindex.Cursor): return False +def derived_virtual_base_class(node: clang.cindex.Cursor): + # This method assumes that the node is a class/struct + + result = False + for child in node.get_children(): + if child.kind != clang.cindex.CursorKind.CXX_BASE_SPECIFIER: + continue + + if clang.cindex.conf.lib.clang_isVirtualBase(child): + result = True + else: + class_or_struct_node = clang.cindex.conf.lib.clang_getCursorDefinition(child) + if class_or_struct_node is None: + continue + + result = derived_virtual_base_class(class_or_struct_node) + + if result: + break + + return result + + def is_function_inline(node: clang.cindex.CursorKind): # This method assumes that the node is a FUNCTION_DECL. # There is no explicit way to check if a function is inlined @@ -125,7 +148,7 @@ def get_namespace_str(node: clang.cindex.Cursor) -> list[str]: return get_namespace_str(node.semantic_parent) + [spelling] -def traverse_ast(node: clang.cindex.Cursor, filename: str, result: set[str]) -> set[str]: +def traverse_ast(node: clang.cindex.Cursor, filename: str, result: set[str]) -> set[str]: # Ignore private and protected variables if (node.access_specifier == clang.cindex.AccessSpecifier.PRIVATE): return result @@ -150,6 +173,8 @@ def traverse_ast(node: clang.cindex.Cursor, filename: str, result: set[str]) -> or node.kind == clang.cindex.CursorKind.STRUCT_DECL): if has_vtable(node): result.add(f"vtable?for?{namespace_str};") + if derived_virtual_base_class(node): + result.add(f"VTT?for?{namespace_str};") result.add(f"typeinfo?for?{namespace_str};") else: def add_internal(s: str):