A couple questions about demangling.
My first question comes from a desire to ensure precise dependencies in our build system. Specifically, we're interested in precise project dependencies, not as focused on SDK dependencies.
Swift allows some cases of referencing symbols from transitive dependencies. To identify these references, I am considering using undefined symbols from object files.
Is it a valid approach to identify gaps in dependencies by demangling an object file's undefined symbols, and get the module name from those symbols? For example using
getModuleName produce any false positives/negatives? In other words, are there any cases where say module A will define a symbol that that returns some other module M, from
One issue is I've seen that
getModuleName returns the empty string for some symbols, even some that have a
Module node. So as an alternative to using
getModuleName, I was considering a breadth first search of the demangled node tree, and taking the first node with
Kind == Module. Would this produce more accurate results, since it includes the symbols that
getModuleName would otherwise exclude, or would it produce false positives?
The other question I have is minor/learning.
I wrote a tool to identify the "primary" kind of a symbol, for example
Variable, etc. I'm wondering whether the heuristic I used is valid. The tool does a bfs of the node tree to find the first node that is either a non-context node (
not isContext(node)), or a node that has multiple children (
node->getNumChildren() > 1). In my manual use, this seems to produce decent results.