[clang] [Sema] Mark alias/ifunc targets used and consider mangled names (PR #87130)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 16 10:54:35 PDT 2024


MaskRay wrote:

> This broke a bot, I reverted and it's back green here: [lab.llvm.org/buildbot/#/builders/272/builds/14069](https://lab.llvm.org/buildbot/#/builders/272/builds/14069)

Thanks. llvm-project/libc has a pattern like the following.

```
namespace libc {
double log2(double x);
}
extern "C" double log2(double);

namespace std {
using ::log2;
}
using std::log2;

namespace libc {
decltype(libc::log2) __log2_impl__ __asm__("log2");
decltype(libc::log2) log2 __attribute__((alias("log2")));
double __log2_impl__(double x) { return x; }
}
```


`ItaniumMangleContextImpl::mangleCXXName` called by `mangleName` (new code in this PR) asserts that the parameter is one of FunctionDecl/VariableDecl/TemplateParamObjectDecl and fails on a `UsingShadowDecl`.
We can check `FunctionDecl` before `mangleCXXName` (we only handle global namespace names, where variables are not mangled).

To make the regression test more useful, I'll place it in `CodeGen/alias.cpp` separately.

https://github.com/llvm/llvm-project/pull/87130


More information about the cfe-commits mailing list