llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Boaz Brickner (bricknerb) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/115464.diff 1 Files Affected: - (modified) clang/lib/Sema/SemaDecl.cpp (+29-5) ``````````diff diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c9cd81a48fbe51..2c52f98b1c8f3d 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6868,11 +6868,7 @@ void Sema::deduceOpenCLAddressSpace(ValueDecl *Decl) { } } -static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) { - // Ensure that an auto decl is deduced otherwise the checks below might cache - // the wrong linkage. - assert(S.ParsingInitForAutoVars.count(&ND) == 0); - +static void checkWeakAttr(Sema &S, NamedDecl &ND) { // 'weak' only applies to declarations with external linkage. if (WeakAttr *Attr = ND.getAttr<WeakAttr>()) { if (!ND.isExternallyVisible()) { @@ -6880,13 +6876,18 @@ static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) { ND.dropAttr<WeakAttr>(); } } +} + +static void checkWeakRefAttr(Sema &S, NamedDecl &ND) { if (WeakRefAttr *Attr = ND.getAttr<WeakRefAttr>()) { if (ND.isExternallyVisible()) { S.Diag(Attr->getLocation(), diag::err_attribute_weakref_not_static); ND.dropAttrs<WeakRefAttr, AliasAttr>(); } } +} +static void checkAliasAttr(Sema &S, NamedDecl &ND) { if (auto *VD = dyn_cast<VarDecl>(&ND)) { if (VD->hasInit()) { if (const auto *Attr = VD->getAttr<AliasAttr>()) { @@ -6897,7 +6898,9 @@ static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) { } } } +} +static void checkSelectAnyAttr(Sema &S, NamedDecl &ND) { // 'selectany' only applies to externally visible variable declarations. // It does not apply to functions. if (SelectAnyAttr *Attr = ND.getAttr<SelectAnyAttr>()) { @@ -6907,12 +6910,17 @@ static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) { ND.dropAttr<SelectAnyAttr>(); } } +} +static void checkHybridPatchableAttr(Sema &S, NamedDecl &ND) { if (HybridPatchableAttr *Attr = ND.getAttr<HybridPatchableAttr>()) { if (!ND.isExternallyVisible()) S.Diag(Attr->getLocation(), diag::warn_attribute_hybrid_patchable_non_extern); } +} + +static void checkInheritableAttr(Sema &S, NamedDecl &ND) { if (const InheritableAttr *Attr = getDLLAttr(&ND)) { auto *VD = dyn_cast<VarDecl>(&ND); bool IsAnonymousNS = false; @@ -6937,7 +6945,9 @@ static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) { ND.setInvalidDecl(); } } +} +static void checkLifetimeBoundAttr(Sema &S, NamedDecl &ND) { // Check the attributes on the function type and function params, if any. if (const auto *FD = dyn_cast<FunctionDecl>(&ND)) { // Don't declare this variable in the second operand of the for-statement; @@ -6989,6 +6999,20 @@ static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) { } } +static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) { + // Ensure that an auto decl is deduced otherwise the checks below might cache + // the wrong linkage. + assert(S.ParsingInitForAutoVars.count(&ND) == 0); + + checkWeakAttr(S, ND); + checkWeakRefAttr(S, ND); + checkAliasAttr(S, ND); + checkSelectAnyAttr(S, ND); + checkHybridPatchableAttr(S, ND); + checkInheritableAttr(S, ND); + checkLifetimeBoundAttr(S, ND); +} + static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl, NamedDecl *NewDecl, bool IsSpecialization, `````````` </details> https://github.com/llvm/llvm-project/pull/115464 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits