[clang] [Clang] Fix isWeakImported() to traverse redeclaration chain for avai… (PR #181482)
via cfe-commits
cfe-commits at lists.llvm.org
Sat May 2 01:50:05 PDT 2026
================
@@ -0,0 +1,39 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -triple arm64-apple-ios12.0 -fmodules-cache-path=%t \
+// RUN: -fmodules -fimplicit-module-maps \
+// RUN: -I %S/Inputs/availability-redecl-weak \
+// RUN: -DINTERFACE_FIRST -emit-llvm -o - %s | FileCheck %s
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -triple arm64-apple-ios12.0 -fmodules-cache-path=%t \
+// RUN: -fmodules -fimplicit-module-maps \
+// RUN: -I %S/Inputs/availability-redecl-weak \
+// RUN: -emit-llvm -o - %s | FileCheck %s
+
+// Test that isWeakImported() traverses the redeclaration chain across module
+// boundaries to find availability attributes.
----------------
kevinlzh1108 wrote:
Done. I've narrowed the change to only ASTReaderDecl.cpp and updated the test:
- **Dropped DeclBase.cpp** — as you pointed out, the Sema path already handles this correctly via `mergeDeclAttributes` + `specific_attrs<InheritableAttr>()`. The PCM path is the only one that needs fixing.
- **Extended `decl-attr-merge.mm`** instead of adding a new test file — added `availability(ios, introduced=14.0)` to the existing `@interface INIntent` and an iOS triple RUN line. Without the fix, `mergeInheritableAttributes`
copies only the first (macOS) attr and drops the iOS one, causing `isWeakImported()` to return false. With the fix, both platform attrs are propagated and the symbol is correctly `extern_weak`.
The PR is now a single fix in `mergeInheritableAttributes` + a test extension.
https://github.com/llvm/llvm-project/pull/181482
More information about the cfe-commits
mailing list