Add optional STL template-name simplification for undecorated C++ names - #49
Add optional STL template-name simplification for undecorated C++ names#49chen3feng wants to merge 1 commit into
Conversation
| @@ -0,0 +1,376 @@ | |||
| /******************************************************************************* | |||
There was a problem hiding this comment.
The intent remains unclear. What are the benefits of this approach? The original Dependency Walker does not simplify the data (even as an option); its sole purpose is to present information exactly as it is from symbols.
There was a problem hiding this comment.
Thanks for the thoughtful pushback — I fully agree that faithfully presenting symbols as-is should remain the tool's default, and this change preserves that: the option is off by default, so nothing changes for users who want raw symbols, and the original name is always one tooltip (or one toggle) away. Nothing is hidden or lost.
The motivation is purely readability for C++ developers. With modern STL, a single std::string parameter expands to ~80 characters of char_traits/allocator boilerplate, and a std::unordered_map line can run off the screen — almost all of it being the default template arguments the compiler synthesized, which by definition carry no information. The feature only collapses those canonical default forms (and only for the std library); user templates and any non-default argument are left exactly as-is, and any unexpected input falls back to the raw string unchanged.
In that sense it's less "altering the data" and more in the same spirit as the demangler already dropping calling-convention/MS keywords for legibility — a display-layer convenience, opt-in, deterministic, and with zero new dependencies.
There was a problem hiding this comment.
Okay, will take your PR into consideration, thank you for feedback and interest in this project!
There was a problem hiding this comment.
@chen3feng
Can you provide a sample to test your code with? It can be Windows dll or specially built test dll.
Have you tested this code with for example msvcp140.dll?
There was a problem hiding this comment.
Thank you, let me show some examples later.
Collapses the canonical default-argument forms produced by the MSVC
demangler into their conventional STL spellings, purely for display:
std::basic_string<char,std::char_traits<char>,std::allocator<char> >
-> std::string
std::vector<T,std::allocator<T> > -> std::vector<T>
std::map<K,V,std::less<K>,std::allocator<...> > -> std::map<K,V>
Only the default-value template forms of the standard library are
matched (basic_string/_view, vector/list/deque/forward_list, set/multiset,
map/multimap, unordered_*, unique_ptr); user templates and non-default
arguments are left untouched. The transform is bracket-aware (walks
balanced angle brackets, folds bottom-up) so nested defaults collapse
correctly, and any unexpected input is returned unchanged so a displayed
name can never be corrupted.
Exposed as a new "Simplify STL Template Names" option on the
Configuration > Appearance page (off by default). Toggling it clears the
cached undecorated names and refreshes the view. The original names remain
available via the existing tooltip.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
52ba5c8 to
9a4e51b
Compare
Summary
Adds an optional, display-only simplification of undecorated C++ names that
collapses the canonical default-argument forms emitted by the MSVC demangler
into their conventional STL spellings, e.g.
std::basic_string<char,std::char_traits<char>,std::allocator<char> >std::stringstd::basic_string_view<char,std::char_traits<char> >std::string_viewstd::vector<T,std::allocator<T> >std::vector<T>std::map<K,V,std::less<K>,std::allocator<std::pair<const K,V> > >std::map<K,V>std::unordered_map<K,V,std::hash<K>,std::equal_to<K>,std::allocator<...> >std::unordered_map<K,V>This makes long, allocator-/comparator-heavy template names far easier to read
in the imports/exports lists — the common request that motivated
stl-filt.Scope and design
basic_string/basic_string_view,vector/list/deque/forward_list,set/multiset,map/multimap,unordered_*, andunique_ptr.User templates and non-default arguments are left untouched.
bottom-up) rather than regex-based, because nested template argument lists
(
std::map<int,std::vector<std::string> >, allocators wrappingstd::pairwith commas) cannot be split reliably with regular expressions.
operator</operator<<, lambda names, and unbalanced input are guarded;any unexpected input is returned unchanged so a displayed name can never be
corrupted.
UX
New "Simplify STL Template Names" checkbox on Configuration → Appearance
(off by default). Toggling it clears the cached undecorated names and refreshes
the view. It composes with the existing "Undecorate C++ Functions" option.
Implementation
Symbols/CStlNameSimplifier.cs— the standalone, WinForms-free transformer.CSymbolResolver.SimplifyTemplateDefaultsapplies it at the end ofUndecorateFunctionName.CConfiguration.SimplifyStlNames(persisted, default false), wired throughMainFormand the configuration form.Tests
A decoupled xUnit project (
WinDepends.StlSimplifier.Tests) links only thesimplifier source — no WinForms / windows-specific TFM — and covers folding,
bottom-up nesting, the function-signature case,
operator</<<guards, usertemplates, and malformed-input fallbacks. 23/23 passing.
Incidental
The repository had no
.gitignore; one for .NET/C++ build artifacts is includedas a separate commit. Happy to drop it from this PR if you'd prefer it separate.
🤖 Generated with Claude Code