[PATCH] D88263: Sema: remove unnecessary parameter for SwiftName handling (NFCI)
Saleem Abdulrasool via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 24 14:53:52 PDT 2020
compnerd created this revision.
compnerd added reviewers: aaron.ballman, gribozavr2.
Herald added a project: clang.
compnerd requested review of this revision.
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!
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88263
Files:
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
Index: clang/lib/Sema/SemaDeclAttr.cpp
===================================================================
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4282,13 +4282,8 @@
}
SwiftNameAttr *Sema::mergeSwiftNameAttr(Decl *D, const SwiftNameAttr &SNA,
- StringRef Name, bool Override) {
+ StringRef Name) {
if (const auto *PrevSNA = D->getAttr<SwiftNameAttr>()) {
- if (Override) {
- // FIXME: warn about incompatible override
- return nullptr;
- }
-
if (PrevSNA->getName() != Name && !PrevSNA->isImplicit()) {
Diag(PrevSNA->getLocation(), diag::err_attributes_are_not_compatible)
<< PrevSNA << &SNA;
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2593,8 +2593,7 @@
} else if (const auto *MA = dyn_cast<MinSizeAttr>(Attr))
NewAttr = S.mergeMinSizeAttr(D, *MA);
else if (const auto *SNA = dyn_cast<SwiftNameAttr>(Attr))
- NewAttr = S.mergeSwiftNameAttr(D, *SNA, SNA->getName(),
- AMK == Sema::AMK_Override);
+ NewAttr = S.mergeSwiftNameAttr(D, *SNA, SNA->getName());
else if (const auto *OA = dyn_cast<OptimizeNoneAttr>(Attr))
NewAttr = S.mergeOptimizeNoneAttr(D, *OA);
else if (const auto *InternalLinkageA = dyn_cast<InternalLinkageAttr>(Attr))
Index: clang/include/clang/Sema/Sema.h
===================================================================
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -3070,7 +3070,7 @@
mergeSpeculativeLoadHardeningAttr(Decl *D,
const SpeculativeLoadHardeningAttr &AL);
SwiftNameAttr *mergeSwiftNameAttr(Decl *D, const SwiftNameAttr &SNA,
- StringRef Name, bool Override);
+ StringRef Name);
OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D,
const AttributeCommonInfo &CI);
InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88263.294177.patch
Type: text/x-patch
Size: 2211 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200924/d1c81e08/attachment.bin>
More information about the cfe-commits
mailing list