Skip to content

Commit 79a6aac

Browse files
committed
AST: Avoid expensive calls to getAttachedPropertyWrappers()
Check for the presence of a CustomAttr first, before calling into the request evaluator. Also clean up the logic a tiny bit.
1 parent 3ee209d commit 79a6aac

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

lib/AST/Decl.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5937,17 +5937,33 @@ llvm::TinyPtrVector<CustomAttr *> VarDecl::getAttachedPropertyWrappers() const {
59375937

59385938
/// Whether this property has any attached property wrappers.
59395939
bool VarDecl::hasAttachedPropertyWrapper() const {
5940-
return !getAttachedPropertyWrappers().empty() || hasImplicitPropertyWrapper();
5940+
if (getAttrs().hasAttribute<CustomAttr>()) {
5941+
if (!getAttachedPropertyWrappers().empty())
5942+
return true;
5943+
}
5944+
5945+
if (hasImplicitPropertyWrapper())
5946+
return true;
5947+
5948+
return false;
59415949
}
59425950

59435951
bool VarDecl::hasImplicitPropertyWrapper() const {
5944-
if (!getAttachedPropertyWrappers().empty())
5952+
if (getAttrs().hasAttribute<CustomAttr>()) {
5953+
if (!getAttachedPropertyWrappers().empty())
5954+
return false;
5955+
}
5956+
5957+
if (isImplicit())
59455958
return false;
59465959

5947-
auto *dc = getDeclContext();
5948-
bool isClosureParam = isa<ParamDecl>(this) &&
5949-
dc->getContextKind() == DeclContextKind::AbstractClosureExpr;
5950-
return !isImplicit() && getName().hasDollarPrefix() && isClosureParam;
5960+
if (!isa<ParamDecl>(this))
5961+
return false;
5962+
5963+
if (!isa<AbstractClosureExpr>(getDeclContext()))
5964+
return false;
5965+
5966+
return getName().hasDollarPrefix();
59515967
}
59525968

59535969
bool VarDecl::hasExternalPropertyWrapper() const {

0 commit comments

Comments
 (0)