Skip to content

Commit 76eb163

Browse files
committed
Sema: remove unnecessary parameter for SwiftName handling (NFCI)
This code never actually did anything in the implementation. `mergeDeclAttribute` is declared as `static`, and referenced exactly once in the file: from `Sema::mergeDeclAttributes`. `Sema::mergeDeclAttributes` sets `LocalAMK` to `AMK_None`. If the attribute is `DeprecatedAttr`, `UnavailableAttr`, or `AvailabilityAttr` then the `LocalAMK` is updated. However, because we are dealing with a `SwiftNameDeclAttr` here, `LocalAMK` remains `AMK_None`. This is then passed to the function which will as a result pass the value of `AMK_None == AMK_Override` aka `false`. Simply propagate the value through and erase the dead codepath. Thanks to Aaron Ballman for flagging the use of the availability merge kind here leading to this simplification! Differential Revision: https://reviews.llvm.org/D88263 Reviewed By: Aaron Ballman
1 parent b5e87c9 commit 76eb163

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3070,7 +3070,7 @@ class Sema final {
30703070
mergeSpeculativeLoadHardeningAttr(Decl *D,
30713071
const SpeculativeLoadHardeningAttr &AL);
30723072
SwiftNameAttr *mergeSwiftNameAttr(Decl *D, const SwiftNameAttr &SNA,
3073-
StringRef Name, bool Override);
3073+
StringRef Name);
30743074
OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D,
30753075
const AttributeCommonInfo &CI);
30763076
InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL);

clang/lib/Sema/SemaDecl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2593,8 +2593,7 @@ static bool mergeDeclAttribute(Sema &S, NamedDecl *D,
25932593
} else if (const auto *MA = dyn_cast<MinSizeAttr>(Attr))
25942594
NewAttr = S.mergeMinSizeAttr(D, *MA);
25952595
else if (const auto *SNA = dyn_cast<SwiftNameAttr>(Attr))
2596-
NewAttr = S.mergeSwiftNameAttr(D, *SNA, SNA->getName(),
2597-
AMK == Sema::AMK_Override);
2596+
NewAttr = S.mergeSwiftNameAttr(D, *SNA, SNA->getName());
25982597
else if (const auto *OA = dyn_cast<OptimizeNoneAttr>(Attr))
25992598
NewAttr = S.mergeOptimizeNoneAttr(D, *OA);
26002599
else if (const auto *InternalLinkageA = dyn_cast<InternalLinkageAttr>(Attr))

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4282,13 +4282,8 @@ NoSpeculativeLoadHardeningAttr *Sema::mergeNoSpeculativeLoadHardeningAttr(
42824282
}
42834283

42844284
SwiftNameAttr *Sema::mergeSwiftNameAttr(Decl *D, const SwiftNameAttr &SNA,
4285-
StringRef Name, bool Override) {
4285+
StringRef Name) {
42864286
if (const auto *PrevSNA = D->getAttr<SwiftNameAttr>()) {
4287-
if (Override) {
4288-
// FIXME: warn about incompatible override
4289-
return nullptr;
4290-
}
4291-
42924287
if (PrevSNA->getName() != Name && !PrevSNA->isImplicit()) {
42934288
Diag(PrevSNA->getLocation(), diag::err_attributes_are_not_compatible)
42944289
<< PrevSNA << &SNA;

0 commit comments

Comments
 (0)