[clang] edfa75d - [clang] [NFC] Split checkAttributesAfterMerging() to multiple functions (#115464)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 12 22:42:54 PST 2024
Author: Boaz Brickner
Date: 2024-11-13T07:42:50+01:00
New Revision: edfa75de33433de29f438fbea4145ec6ae20e020
URL: https://github.com/llvm/llvm-project/commit/edfa75de33433de29f438fbea4145ec6ae20e020
DIFF: https://github.com/llvm/llvm-project/commit/edfa75de33433de29f438fbea4145ec6ae20e020.diff
LOG: [clang] [NFC] Split checkAttributesAfterMerging() to multiple functions (#115464)
Added:
Modified:
clang/lib/Sema/SemaDecl.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 61c29e320d5c73..cb810a8622e11d 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,
More information about the cfe-commits
mailing list