xref: /openbsd-src/gnu/llvm/llvm/docs/CommandGuide/llvm-cxxmap.rst (revision 09467b48e8bc8b4905716062da846024139afbf2)
1*09467b48Spatrickllvm-cxxmap - Mangled name remapping tool
2*09467b48Spatrick=========================================
3*09467b48Spatrick
4*09467b48Spatrick.. program:: llvm-cxxmap
5*09467b48Spatrick
6*09467b48SpatrickSYNOPSIS
7*09467b48Spatrick--------
8*09467b48Spatrick
9*09467b48Spatrick:program:`llvm-cxxmap` [*options*] *symbol-file-1* *symbol-file-2*
10*09467b48Spatrick
11*09467b48SpatrickDESCRIPTION
12*09467b48Spatrick-----------
13*09467b48Spatrick
14*09467b48SpatrickThe :program:`llvm-cxxmap` tool performs fuzzy matching of C++ mangled names,
15*09467b48Spatrickbased on a file describing name components that should be considered equivalent.
16*09467b48Spatrick
17*09467b48SpatrickThe symbol files should contain a list of C++ mangled names (one per line).
18*09467b48SpatrickBlank lines and lines starting with ``#`` are ignored. The output is a list
19*09467b48Spatrickof pairs of equivalent symbols, one per line, of the form
20*09467b48Spatrick
21*09467b48Spatrick.. code-block:: none
22*09467b48Spatrick
23*09467b48Spatrick  <symbol-1> <symbol-2>
24*09467b48Spatrick
25*09467b48Spatrickwhere ``<symbol-1>`` is a symbol from *symbol-file-1* and ``<symbol-2>`` is
26*09467b48Spatricka symbol from *symbol-file-2*. Mappings for which the two symbols are identical
27*09467b48Spatrickare omitted.
28*09467b48Spatrick
29*09467b48SpatrickOPTIONS
30*09467b48Spatrick-------
31*09467b48Spatrick
32*09467b48Spatrick.. program:: llvm-cxxmap
33*09467b48Spatrick
34*09467b48Spatrick.. option:: -remapping-file=file, -r=file
35*09467b48Spatrick
36*09467b48Spatrick Specify a file containing a list of equivalence rules that should be used
37*09467b48Spatrick to determine whether two symbols are equivalent. Required.
38*09467b48Spatrick See :ref:`remapping-file`.
39*09467b48Spatrick
40*09467b48Spatrick.. option:: -output=file, -o=file
41*09467b48Spatrick
42*09467b48Spatrick Specify a file to write the list of matched names to. If unspecified, the
43*09467b48Spatrick list will be written to stdout.
44*09467b48Spatrick
45*09467b48Spatrick.. option:: -Wambiguous
46*09467b48Spatrick
47*09467b48Spatrick Produce a warning if there are multiple equivalent (but distinct) symbols in
48*09467b48Spatrick *symbol-file-2*.
49*09467b48Spatrick
50*09467b48Spatrick.. option:: -Wincomplete
51*09467b48Spatrick
52*09467b48Spatrick Produce a warning if *symbol-file-1* contains a symbol for which there is no
53*09467b48Spatrick equivalent symbol in *symbol-file-2*.
54*09467b48Spatrick
55*09467b48Spatrick.. _remapping-file:
56*09467b48Spatrick
57*09467b48SpatrickREMAPPING FILE
58*09467b48Spatrick--------------
59*09467b48Spatrick
60*09467b48SpatrickThe remapping file is a text file containing lines of the form
61*09467b48Spatrick
62*09467b48Spatrick.. code-block:: none
63*09467b48Spatrick
64*09467b48Spatrick  fragmentkind fragment1 fragment2
65*09467b48Spatrick
66*09467b48Spatrickwhere ``fragmentkind`` is one of ``name``, ``type``, or ``encoding``,
67*09467b48Spatrickindicating whether the following mangled name fragments are
68*09467b48Spatrick<`name <http://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.name>`_>s,
69*09467b48Spatrick<`type <http://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.type>`_>s, or
70*09467b48Spatrick<`encoding <http://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.encoding>`_>s,
71*09467b48Spatrickrespectively.
72*09467b48SpatrickBlank lines and lines starting with ``#`` are ignored.
73*09467b48Spatrick
74*09467b48SpatrickUnmangled C names can be expressed as an ``encoding`` that is a (length-prefixed)
75*09467b48Spatrick<`source-name <http://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.source-name>`_>:
76*09467b48Spatrick
77*09467b48Spatrick.. code-block:: none
78*09467b48Spatrick
79*09467b48Spatrick  # C function "void foo_bar()" is remapped to C++ function "void foo::bar()".
80*09467b48Spatrick  encoding 7foo_bar _Z3foo3barv
81*09467b48Spatrick
82*09467b48SpatrickFor convenience, built-in <substitution>s such as ``St`` and ``Ss``
83*09467b48Spatrickare accepted as <name>s (even though they technically are not <name>s).
84*09467b48Spatrick
85*09467b48SpatrickFor example, to specify that ``absl::string_view`` and ``std::string_view``
86*09467b48Spatrickshould be treated as equivalent, the following remapping file could be used:
87*09467b48Spatrick
88*09467b48Spatrick.. code-block:: none
89*09467b48Spatrick
90*09467b48Spatrick  # absl::string_view is considered equivalent to std::string_view
91*09467b48Spatrick  type N4absl11string_viewE St17basic_string_viewIcSt11char_traitsIcEE
92*09467b48Spatrick
93*09467b48Spatrick  # std:: might be std::__1:: in libc++ or std::__cxx11:: in libstdc++
94*09467b48Spatrick  name St St3__1
95*09467b48Spatrick  name St St7__cxx11
96*09467b48Spatrick
97*09467b48Spatrick.. note::
98*09467b48Spatrick
99*09467b48Spatrick  Symbol remapping is currently only supported for C++ mangled names
100*09467b48Spatrick  following the Itanium C++ ABI mangling scheme. This covers all C++ targets
101*09467b48Spatrick  supported by Clang other than Windows targets.
102