[PATCH] D143803: [clang][alias|ifunc]: Add a diagnostic for mangled names

Dhruv Chawla via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 6 08:11:27 PST 2023


0xdc03 added a comment.

Okay, I have now modified the diagnostic to look like this:

  ../bug/ifunc-#59164.cpp:17:16: error: ifunc must point to a defined function
  __attribute__((ifunc("resolver")))
                 ^
  ../bug/ifunc-#59164.cpp:17:16: note: the function specified in an ifunc must refer to its mangled name
  ../bug/ifunc-#59164.cpp:17:16: note: function by that name is mangled as "_ZL8resolverv"
  __attribute__((ifunc("resolver")))
                 ^~~~~~~~~~~~~~~~~
                 ifunc("_ZL8resolverv")
  ../bug/ifunc-#59164.cpp:20:16: error: alias must point to a defined variable or function
  __attribute__((alias("resolver")))
                 ^
  ../bug/ifunc-#59164.cpp:20:16: note: the function or variable specified in an alias must refer to its mangled name
  ../bug/ifunc-#59164.cpp:20:16: note: function by that name is mangled as "_ZL8resolverv"
  __attribute__((alias("resolver")))
                 ^~~~~~~~~~~~~~~~~
                 alias("_ZL8resolverv")
  ../bug/ifunc-#59164.cpp:23:24: error: ifunc must point to a defined function
  __attribute__((unused, ifunc("resolver"), deprecated("hahahaha, isn't C great?"))) void func();
                         ^
  ../bug/ifunc-#59164.cpp:23:24: note: the function specified in an ifunc must refer to its mangled name
  ../bug/ifunc-#59164.cpp:23:24: note: function by that name is mangled as "_ZL8resolverv"
  __attribute__((unused, ifunc("resolver"), deprecated("hahahaha, isn't C great?"))) void func();
                         ^~~~~~~~~~~~~~~~~
                         ifunc("_ZL8resolverv")
  3 errors generated.

Honestly I think this is good enough, I don't really think its worth bikeshedding over `<mangled name>`. I would anyways expect a user of these features to know how mangling works, so :shrug: from me.

I have also added checks for the fix-its.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143803/new/

https://reviews.llvm.org/D143803



More information about the cfe-commits mailing list