[all-commits] [llvm/llvm-project] 066566: [Sema] Mark alias/ifunc targets used and consider ...

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Apr 16 11:49:48 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0665669876cd7f51f7572cff3bb97485d78f5de5
      https://github.com/llvm/llvm-project/commit/0665669876cd7f51f7572cff3bb97485d78f5de5
  Author: Fangrui Song <i at maskray.me>
  Date:   2024-04-16 (Tue, 16 Apr 2024)

  Changed paths:
    M clang/lib/Sema/CMakeLists.txt
    M clang/lib/Sema/SemaDeclAttr.cpp
    M clang/test/AST/ast-dump-attr-json.cpp
    M clang/test/Sema/alias-unused-win.cpp
    M clang/test/Sema/alias-unused.cpp
    M utils/bazel/llvm-project-overlay/clang/BUILD.bazel

  Log Message:
  -----------
  [Sema] Mark alias/ifunc targets used and consider mangled names

https://reviews.llvm.org/D54188 marked "alias" targets as used in C to
fix -Wunused false positives. This patch extends the approach to handle
mangled names to support global scope names in C++ and the
`overloadable` attribute in C.

(Note: we should skip `UsingShadowDecl`, which would trigger an
assertion failure in `ItaniumMangleContextImpl::mangleCXXName`.
See regression test added by commit 1c2afbae9af22b58190c10e3517242d01d89d612.)

In addition, we mark ifunc targets as used to fix #63957 (temporarily
used by xz; ifunc was removed by
https://github.com/tukaani-project/xz/commit/689ae2427342a2ea1206eb5ca08301baf410e7e0)

While our approach has false negatives for namespace scope names, the
majority of alias/ifunc C++ uses (global scope with no overloads) are
handled.

Note: The following function with internal linkage but C language
linkage type is mangled in Clang but not in GCC. This inconsistency
makes alias/ifunc difficult to use in C++ with portability (#88593).
```
extern "C" {
static void f0() {}
// GCC: void g0() __attribute__((alias("_ZL2f0v")));
// Clang: void g0() __attribute__((alias("f0")));
}
```

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



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list