Skip to content

Commit ab90d09

Browse files
committed
[ASTScope] Eliminate getDeclAttributeIfAny().
We only used this in one place, and then immediately filtered down to a `CustomAttr`. Just use `dyn_cast` in the obvious way and remove this function.
1 parent 742323c commit ab90d09

File tree

3 files changed

+4
-21
lines changed

3 files changed

+4
-21
lines changed

include/swift/AST/ASTScope.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ class ASTScopeImpl : public ASTAllocated<ASTScopeImpl> {
237237
NullablePtr<Decl> getDeclIfAny() const;
238238
NullablePtr<Stmt> getStmtIfAny() const;
239239
NullablePtr<Expr> getExprIfAny() const;
240-
NullablePtr<DeclAttribute> getDeclAttributeIfAny() const;
241240

242241
#pragma mark - debugging and printing
243242

lib/AST/ASTScope.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -170,22 +170,6 @@ NullablePtr<Expr> ASTScopeImpl::getExprIfAny() const {
170170
}
171171
}
172172

173-
NullablePtr<DeclAttribute> ASTScopeImpl::getDeclAttributeIfAny() const {
174-
switch (getKind()) {
175-
// Statement scope nodes extract the statement directly.
176-
#define DECL_ATTRIBUTE_SCOPE_NODE(Name) \
177-
case ScopeKind::Name: return cast<Name##Scope>(this)->getDeclAttr();
178-
#define SCOPE_NODE(Name)
179-
#include "swift/AST/ASTScopeNodes.def"
180-
181-
// Everything else returns nullptr.
182-
#define DECL_ATTRIBUTE_SCOPE_NODE(Name)
183-
#define SCOPE_NODE(Name) case ScopeKind::Name:
184-
#include "swift/AST/ASTScopeNodes.def"
185-
return nullptr;
186-
}
187-
}
188-
189173
SourceManager &ASTScopeImpl::getSourceManager() const {
190174
return getASTContext().SourceMgr;
191175
}

lib/AST/ASTScopeLookup.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -649,10 +649,10 @@ void ASTScopeImpl::lookupEnclosingMacroScope(
649649
return;
650650
}
651651

652-
auto *attr = scope->getDeclAttributeIfAny().getPtrOrNull();
653-
auto *potentialAttached = dyn_cast_or_null<CustomAttr>(attr);
654-
if (potentialAttached && consume(potentialAttached))
655-
return;
652+
if (auto customAttrScope = dyn_cast<CustomAttributeScope>(scope)) {
653+
if (consume(customAttrScope->attr))
654+
return;
655+
}
656656

657657
// If we've reached a source file scope, we can't be inside of
658658
// a macro argument. Either this is a top-level source file, or

0 commit comments

Comments
 (0)