Skip to content

Rename demangle to mat_demangle to avoid boost name conflict#1479

Open
bmehta001 wants to merge 1 commit into
microsoft:mainfrom
bmehta001:bhamehta/rename-demangle-boost-conflict
Open

Rename demangle to mat_demangle to avoid boost name conflict#1479
bmehta001 wants to merge 1 commit into
microsoft:mainfrom
bmehta001:bhamehta/rename-demangle-boost-conflict

Conversation

@bmehta001

Copy link
Copy Markdown
Contributor

What

Rename the SDK's demangle helper (both the function and the function-like macro) in lib/pal/typename.hpp to mat_demangle, and update its sole external caller in lib/utils/Utils.cpp.

Why

typename.hpp defined a global symbol named demangle in two forms:

__inline static std::string demangle(const char* name) { ... }   // RTTI+GNU branch
...
#define demangle(name)  (name)                                    // fallback branch

The fallback function-like macro demangle(name) rewrites every demangle token in any translation unit that includes this header. When the SDK is integrated alongside boost, this clobbers boost::core::demangle (from boost/core/demangle.hpp):

boost::core::demangle(typeid(x).name())
        -->  boost::core::(typeid(x).name())     // macro-expanded: does not compile

This is exactly the build failure reported in #1048.

Fix

Rename the helper to the SDK-scoped mat_demangle (function + macro), update TYPENAME() to use it, and update the single caller (print_backtrace). No behavior change — only the identifier changes.

The only repo-owned references to demangle are the three lines in typename.hpp and one line in Utils.cpp; all are updated.

Validation

A translation unit that includes typename.hpp, uses TYPENAME(int), and defines a namespaced demangle (mimicking boost):

  • Old header: fails to compile — error: expected unqualified-id at the namespaced demangle definition (the macro clobber).
  • This change: compiles cleanly (clang++ -std=c++17 -fsyntax-only, exit 0).

Files

  • lib/pal/typename.hpp
  • lib/utils/Utils.cpp

Resolves #1048.

typename.hpp defined both a global `demangle` function and a function-like
macro `#define demangle(name) (name)`. The macro rewrites any `demangle`
token in translation units that include this header -- including
`boost::core::demangle` from boost/core/demangle.hpp -- producing a
compile error when the SDK is integrated alongside boost.

Rename the SDK helper (function + macro) to `mat_demangle` and update its
sole external caller (print_backtrace in Utils.cpp). TYPENAME() is updated
to match. No behavior change.

Verified: a TU that includes typename.hpp and defines a namespaced
`demangle` (as boost does) fails to compile with the old header and
compiles cleanly after the rename (clang++ -std=c++17 -fsyntax-only).

Files: lib/pal/typename.hpp, lib/utils/Utils.cpp

Resolves microsoft#1048.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bmehta001 bmehta001 requested a review from a team as a code owner June 11, 2026 05:21
@bmehta001 bmehta001 self-assigned this Jun 11, 2026
@bmehta001 bmehta001 requested a review from Copilot June 11, 2026 08:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request renames the SDK’s global demangle helper (both the inline function and the fallback function-like macro) to mat_demangle to prevent macro expansion from clobbering boost::core::demangle in downstream integrations.

Changes:

  • Renamed demanglemat_demangle in lib/pal/typename.hpp (function, macro, and TYPENAME() usage).
  • Updated the only in-repo external usage in print_backtrace to call mat_demangle.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/pal/typename.hpp Renames the demangling helper and updates TYPENAME() to use mat_demangle, avoiding Boost symbol breakage from a demangle(...) macro.
lib/utils/Utils.cpp Updates print_backtrace to call the renamed helper (mat_demangle).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build issue with conflicting demangle definition with boost/core/demangle.hpp

2 participants