From 6c7120d684cc46caafbe348d658158c0060a7638 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 5 Jul 2023 14:37:48 -0700 Subject: Bottleneck DeclRef creation through ASTBuilder. (#2689) * Bottleneck DeclRef creation through ASTBuilder. * Fix clang error. * Fix. * Fix. * More fix. * Rebase on top of tree. --------- Co-authored-by: Yong He --- source/slang/slang-lookup.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source/slang/slang-lookup.cpp') diff --git a/source/slang/slang-lookup.cpp b/source/slang/slang-lookup.cpp index 484797344..0c4279761 100644 --- a/source/slang/slang-lookup.cpp +++ b/source/slang/slang-lookup.cpp @@ -167,7 +167,7 @@ static void _lookUpDirectAndTransparentMembers( AddToLookupResult( result, CreateLookupResultItem( - DeclRef(member, containerDeclRef.substitutions), inBreadcrumbs)); + astBuilder->getSpecializedDeclRef(member, containerDeclRef.substitutions), inBreadcrumbs)); } } else @@ -186,7 +186,7 @@ static void _lookUpDirectAndTransparentMembers( continue; // The declaration passed the test, so add it! - AddToLookupResult(result, CreateLookupResultItem(DeclRef(m, containerDeclRef.substitutions), inBreadcrumbs)); + AddToLookupResult(result, CreateLookupResultItem(astBuilder->getSpecializedDeclRef(m, containerDeclRef.substitutions), inBreadcrumbs)); } } @@ -196,7 +196,7 @@ static void _lookUpDirectAndTransparentMembers( { // The reference to the transparent member should use whatever // substitutions we used in referring to its outer container - DeclRef transparentMemberDeclRef(transparentInfo.decl, containerDeclRef.substitutions); + DeclRef transparentMemberDeclRef = astBuilder->getSpecializedDeclRef(transparentInfo.decl, containerDeclRef.substitutions); // We need to leave a breadcrumb so that we know that the result // of lookup involves a member lookup step here @@ -307,7 +307,7 @@ static Type* _maybeSpecializeSuperType( thisTypeSubst->witness = subIsSuperWitness; thisTypeSubst->outer = superInterfaceDeclRef.substitutions.substitutions; - auto specializedInterfaceDeclRef = DeclRef(superInterfaceDeclRef.getDecl(), thisTypeSubst); + auto specializedInterfaceDeclRef = astBuilder->getSpecializedDeclRef(superInterfaceDeclRef.getDecl(), thisTypeSubst); auto specializedInterfaceType = DeclRefType::create(astBuilder, specializedInterfaceDeclRef); return specializedInterfaceType; @@ -432,10 +432,10 @@ static void _lookUpMembersInSuperTypeDeclImpl( // then the members it provides can only be discovered by looking // at the constraints that are placed on that type. - auto genericDeclRef = genericTypeParamDeclRef.getParent().as(); + auto genericDeclRef = genericTypeParamDeclRef.getParent(astBuilder).as(); assert(genericDeclRef); - for(auto constraintDeclRef : getMembersOfType(genericDeclRef)) + for(auto constraintDeclRef : getMembersOfType(astBuilder, genericDeclRef)) { if( semantics ) { @@ -467,7 +467,7 @@ static void _lookUpMembersInSuperTypeDeclImpl( } else if (declRef.as() || declRef.as()) { - for (auto constraintDeclRef : getMembersOfType(declRef.as())) + for (auto constraintDeclRef : getMembersOfType(astBuilder, declRef.as())) { _lookUpMembersInSuperType( astBuilder, @@ -534,7 +534,7 @@ static void _lookUpMembersInSuperTypeDeclImpl( // through the declared inheritance relationships on each declaration. // ensureDecl(semantics, aggTypeDeclBaseRef.getDecl(), DeclCheckState::CanEnumerateBases); - for (auto inheritanceDeclRef : getMembersOfType(aggTypeDeclBaseRef)) + for (auto inheritanceDeclRef : getMembersOfType(astBuilder, aggTypeDeclBaseRef)) { ensureDecl(semantics, inheritanceDeclRef.getDecl(), DeclCheckState::CanUseBaseOfInheritanceDecl); @@ -801,7 +801,7 @@ static void _lookUpInScopes( // just a decl. // DeclRef containerDeclRef = - DeclRef(containerDecl, createDefaultSubstitutions(astBuilder, request.semantics, containerDecl)).as(); + astBuilder->getSpecializedDeclRef(containerDecl, createDefaultSubstitutions(astBuilder, request.semantics, containerDecl)).as(); // If the container we are looking into represents a type // or an `extension` of a type, then we need to treat -- cgit v1.2.3