Skip to content

Commit cd217d7

Browse files
authored
Merge pull request #26688 from slavapestov/refactor-decl-attr-checking
Refactor declaration attribute checking
2 parents bdb52b3 + 5213153 commit cd217d7

18 files changed

+790
-1017
lines changed

include/swift/AST/Decl.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class alignas(1 << DeclAlignInBits) Decl {
286286
protected:
287287
union { uint64_t OpaqueBits;
288288

289-
SWIFT_INLINE_BITFIELD_BASE(Decl, bitmax(NumDeclKindBits,8)+1+1+1+1+1+1+1,
289+
SWIFT_INLINE_BITFIELD_BASE(Decl, bitmax(NumDeclKindBits,8)+1+1+1+1+2+1,
290290
Kind : bitmax(NumDeclKindBits,8),
291291

292292
/// Whether this declaration is invalid.
@@ -301,10 +301,6 @@ class alignas(1 << DeclAlignInBits) Decl {
301301
/// Use getClangNode() to retrieve the corresponding Clang AST.
302302
FromClang : 1,
303303

304-
/// Whether we've already performed early attribute validation.
305-
/// FIXME: This is ugly.
306-
EarlyAttrValidation : 1,
307-
308304
/// The validation state of this declaration.
309305
ValidationState : 2,
310306

@@ -694,7 +690,6 @@ class alignas(1 << DeclAlignInBits) Decl {
694690
Bits.Decl.Invalid = false;
695691
Bits.Decl.Implicit = false;
696692
Bits.Decl.FromClang = false;
697-
Bits.Decl.EarlyAttrValidation = false;
698693
Bits.Decl.ValidationState = unsigned(ValidationState::Unchecked);
699694
Bits.Decl.EscapedFromIfConfig = false;
700695
}
@@ -836,14 +831,6 @@ class alignas(1 << DeclAlignInBits) Decl {
836831
/// Mark this declaration as implicit.
837832
void setImplicit(bool implicit = true) { Bits.Decl.Implicit = implicit; }
838833

839-
/// Whether we have already done early attribute validation.
840-
bool didEarlyAttrValidation() const { return Bits.Decl.EarlyAttrValidation; }
841-
842-
/// Set whether we've performed early attribute validation.
843-
void setEarlyAttrValidation(bool validated = true) {
844-
Bits.Decl.EarlyAttrValidation = validated;
845-
}
846-
847834
/// Get the validation state.
848835
ValidationState getValidationState() const {
849836
return ValidationState(Bits.Decl.ValidationState);

lib/AST/ASTVerifier.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -968,12 +968,8 @@ class Verifier : public ASTWalker {
968968
Overridden->dump(Out);
969969
abort();
970970
}
971-
}
972-
973-
if (D->didEarlyAttrValidation() &&
974-
D->getAttrs().hasAttribute<OverrideAttr>()) {
975-
if (!D->isInvalid() && D->hasInterfaceType() &&
976-
!isa<ClassDecl>(D->getDeclContext()) &&
971+
972+
if (!isa<ClassDecl>(D->getDeclContext()) &&
977973
!isa<ProtocolDecl>(D->getDeclContext()) &&
978974
!isa<ExtensionDecl>(D->getDeclContext())) {
979975
PrettyStackTraceDecl debugStack("verifying override", D);
@@ -983,7 +979,6 @@ class Verifier : public ASTWalker {
983979
}
984980
}
985981

986-
987982
verifyCheckedAlwaysBase(D);
988983
}
989984

lib/ClangImporter/ImportDecl.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,6 @@ static void addSynthesizedTypealias(NominalTypeDecl *nominal, Identifier name,
14901490
name, SourceLoc(),
14911491
nullptr, nominal);
14921492
typealias->setUnderlyingType(underlyingType);
1493-
typealias->setEarlyAttrValidation(true);
14941493
typealias->setAccess(AccessLevel::Public);
14951494
typealias->setValidationToChecked();
14961495
typealias->setImplicit();

lib/ClangImporter/ImporterImpl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,6 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
12921292
true);
12931293
auto D = ::new (DeclPtr) DeclTy(std::forward<Targs>(Args)...);
12941294
D->setClangNode(ClangN);
1295-
D->setEarlyAttrValidation(true);
12961295
D->setAccess(access);
12971296
if (auto ASD = dyn_cast<AbstractStorageDecl>(D))
12981297
ASD->setSetterAccess(access);

lib/Sema/DerivedConformanceEquatableHashable.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,6 @@ deriveEquatable_eq(
719719
parentDC);
720720
eqDecl->setImplicit();
721721
eqDecl->setUserAccessible(false);
722-
eqDecl->getAttrs().add(new (C) InfixAttr(/*implicit*/false));
723722

724723
// Add the @_implements(Equatable, ==(_:_:)) attribute
725724
if (generatedIdentifier != C.Id_EqualsOperator) {

0 commit comments

Comments
 (0)