From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3D66A384803D; Thu, 10 Jun 2021 21:08:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D66A384803D From: "hedayat.fwd at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/101010] Feature request: add builtins to provide mangled symbols, optionally with a prefix Date: Thu, 10 Jun 2021 21:08:30 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: hedayat.fwd at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jun 2021 21:08:31 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101010 --- Comment #2 from Hedayat Vatankhah --- (In reply to Martin Sebor from comment #1) > Does the type_info::name() string match what you're looking for? No, not at all. Looks like I've not clearly described my intent.=20 First of all, type_info::name() is a runtime function. Both builtins I asked are compile-time builtins: they should be replaced at compile time with the desired string or symbol. Also, I want the symbol name of the referred function or variable, not its type. What your sample program outputs is the mangled name of type "void (MyClass::*)(MyClass*, int)", but what I want is the mangled name of symbol "void MyClass::member(MyClass*, int)".=20 Finally, I asked about two distinct type of builtins: 1. The first kind is replaced at compile time with the mangled name as a string. This kind, makes the following possible (note that probably droppin= g & makes it more clear): void f() __attribute__ ((weak, alias (__builtin_mangle(MyClass::member)))); Should become same as the following: void f() __attribute__ ((weak, alias ("_ZN7MyClass6memberEi"))); 2. The second kind, does not generate a "string"; It generates a symbol at compile time. Consider the example I provided in comment 0, it should be converted to the following at compile time: void __wrap__ZN7MyClass6memberEi(MyClass *mc_this, int a) { if (call_real) __real__ZN7MyClass6memberEi(mc_this, a); else {...} }=