@@ -52,7 +52,6 @@ void * realloc ();
5252#define CURRENT_DEMANGLING_STYLE options
5353
5454#include "libiberty.h"
55- #include "rust-demangle.h"
5655
5756enum demangling_styles current_demangling_style = auto_demangling ;
5857
@@ -160,27 +159,20 @@ cplus_demangle (const char *mangled, int options)
160159 if ((options & DMGL_STYLE_MASK ) == 0 )
161160 options |= (int ) current_demangling_style & DMGL_STYLE_MASK ;
162161
162+ /* The Rust demangling is implemented elsewhere.
163+ Legacy Rust symbols overlap with GNU_V3, so try Rust first. */
164+ if (RUST_DEMANGLING || AUTO_DEMANGLING )
165+ {
166+ ret = rust_demangle (mangled , options );
167+ if (ret || RUST_DEMANGLING )
168+ return ret ;
169+ }
170+
163171 /* The V3 ABI demangling is implemented elsewhere. */
164- if (GNU_V3_DEMANGLING || RUST_DEMANGLING || AUTO_DEMANGLING )
172+ if (GNU_V3_DEMANGLING || AUTO_DEMANGLING )
165173 {
166174 ret = cplus_demangle_v3 (mangled , options );
167- if (GNU_V3_DEMANGLING )
168- return ret ;
169-
170- if (ret )
171- {
172- /* Rust symbols are GNU_V3 mangled plus some extra subtitutions.
173- The subtitutions are always smaller, so do in place changes. */
174- if (rust_is_mangled (ret ))
175- rust_demangle_sym (ret );
176- else if (RUST_DEMANGLING )
177- {
178- free (ret );
179- ret = NULL ;
180- }
181- }
182-
183- if (ret || RUST_DEMANGLING )
175+ if (ret || GNU_V3_DEMANGLING )
184176 return ret ;
185177 }
186178
@@ -204,27 +196,6 @@ cplus_demangle (const char *mangled, int options)
204196 return (ret );
205197}
206198
207- char *
208- rust_demangle (const char * mangled , int options )
209- {
210- /* Rust symbols are GNU_V3 mangled plus some extra subtitutions. */
211- char * ret = cplus_demangle_v3 (mangled , options );
212-
213- /* The Rust subtitutions are always smaller, so do in place changes. */
214- if (ret != NULL )
215- {
216- if (rust_is_mangled (ret ))
217- rust_demangle_sym (ret );
218- else
219- {
220- free (ret );
221- ret = NULL ;
222- }
223- }
224-
225- return ret ;
226- }
227-
228199/* Demangle ada names. The encoding is documented in gcc/ada/exp_dbug.ads. */
229200
230201char *
0 commit comments