Skip to content

Commit 161c837

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 56da3f4 commit 161c837

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
@@ -5936,17 +5936,33 @@ llvm::TinyPtrVector<CustomAttr *> VarDecl::getAttachedPropertyWrappers() const {
59365936

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

59425950
bool VarDecl::hasImplicitPropertyWrapper() const {
5943-
if (!getAttachedPropertyWrappers().empty())
5951+
if (getAttrs().hasAttribute<CustomAttr>()) {
5952+
if (!getAttachedPropertyWrappers().empty())
5953+
return false;
5954+
}
5955+
5956+
if (isImplicit())
59445957
return false;
59455958

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

59525968
bool VarDecl::hasExternalPropertyWrapper() const {

0 commit comments

Comments
 (0)