14 Commits

Author SHA1 Message Date
Fangrui Song
0665669876 [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
689ae24273)

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
2024-04-16 11:49:25 -07:00
Mehdi Amini
51b42b7621
Revert "[Sema] Mark alias/ifunc targets used and consider mangled names" (#88919)
Reverts llvm/llvm-project#87130

Bot is broken with clang crash:
https://lab.llvm.org/buildbot/#/builders/272/builds/14063/steps/6/logs/stdio
2024-04-16 17:45:02 +02:00
Fangrui Song
2ac562ab78
[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.

In addition, we mark ifunc targets as used to fix #63957.

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
2024-04-15 17:58:39 -07:00
serge-sans-paille
cda319851f
[clang] Add missing field to TLSModelAttr json AST dump
Recommit with test case updated.

Differential Revision: https://reviews.llvm.org/D157814
2023-08-15 22:24:42 +02:00
serge-sans-paille
f2dd62f6ca
[clang] Add missing field to VisibilityAttr json AST dump
Recommit with test file updated.

Differential Revision: https://reviews.llvm.org/D157808
2023-08-15 22:24:42 +02:00
Hans Wennborg
7a1735cd05 Add a triple to clang/test/AST/ast-dump-attr-json.cpp
Otherwise the mangledName field won't match.
2023-08-15 17:05:31 +02:00
Douglas Yung
b7e1d26f84 Revert "[clang] Add missing field to VisibilityAttr json AST dump"
This reverts commit 2107d87c5a9103ffc4c0f76fc00ab203603f9df1.

Change is causing test failures on many bots:
- https://lab.llvm.org/buildbot/#/builders/164/builds/42180
- https://lab.llvm.org/buildbot/#/builders/188/builds/33880
- https://lab.llvm.org/buildbot/#/builders/245/builds/12558
- https://lab.llvm.org/buildbot/#/builders/258/builds/5404
- https://lab.llvm.org/buildbot/#/builders/249/builds/8049
- https://lab.llvm.org/buildbot/#/builders/230/builds/17170
- https://lab.llvm.org/buildbot/#/builders/91/builds/17108
- https://lab.llvm.org/buildbot/#/builders/109/builds/71264
- https://lab.llvm.org/buildbot/#/builders/139/builds/47461
- https://lab.llvm.org/buildbot/#/builders/216/builds/25598
- https://lab.llvm.org/buildbot/#/builders/36/builds/36549
- https://lab.llvm.org/buildbot/#/builders/247/builds/7747
2023-08-14 16:15:30 -07:00
Douglas Yung
4ac4d4a977 Revert "[clang] Add missing field to TLSModelAttr json AST dump"
This reverts commit 2105c32b32bf3360f524f1f3a1e5af605821eff8.

Reverting this follow-up commit as a prior commit (2107d87) is causing build bot test failures.
2023-08-14 16:14:28 -07:00
serge-sans-paille
2105c32b32
[clang] Add missing field to TLSModelAttr json AST dump
Differential Revision: https://reviews.llvm.org/D157814
2023-08-14 22:59:45 +02:00
serge-sans-paille
2107d87c5a
[clang] Add missing field to VisibilityAttr json AST dump
Differential Revision: https://reviews.llvm.org/D157808
2023-08-14 22:59:45 +02:00
serge-sans-paille
4cf7666b8f
[clang] Add missing field to SectionAttr json AST dump
Differential Revision: https://reviews.llvm.org/D157795
2023-08-14 22:59:45 +02:00
serge-sans-paille
3dadc290b2
[clang] Add missing fields to DeprecatedAttr and Unavailable json AST dump
Differential Revision: https://reviews.llvm.org/D157783
2023-08-14 22:59:45 +02:00
serge-sans-paille
903e530bb8
[clang] Add cleanup_function field to CleanupAttr json AST dump
Differential Revision: https://reviews.llvm.org/D157781
2023-08-14 22:59:45 +02:00
serge-sans-paille
11f3286585
[clang] Add aliasee field to AliasAttr json AST dump
Differential Revision: https://reviews.llvm.org/D157775
2023-08-14 22:59:40 +02:00