Skip to content

Commit 7f031df

Browse files
committed
Drop unnecessary "parent context" state from TypeRefinementContextBuilder
This state is a holdover from when accessors we stored "alongside" their variable declarations, rather than contained within them. That's no longer the case, so we don't need to track this information any more.
1 parent c098175 commit 7f031df

File tree

1 file changed

+0
-67
lines changed

1 file changed

+0
-67
lines changed

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -388,20 +388,6 @@ class TypeRefinementContextBuilder : private ASTWalker {
388388
};
389389
std::vector<DeclBodyContextInfo> DeclBodyContextStack;
390390

391-
/// A mapping from abstract storage declarations with accessors to
392-
/// to the type refinement contexts for those declarations. We refer to
393-
/// this map to determine the appropriate parent TRC to use when
394-
/// walking the accessor function.
395-
llvm::DenseMap<AbstractStorageDecl *, TypeRefinementContext *>
396-
StorageContexts;
397-
398-
/// A mapping from pattern binding storage declarations to the type refinement
399-
/// contexts for those declarations. We refer to this map to determine the
400-
/// appropriate parent TRC to use when walking a var decl that belongs to a
401-
/// pattern containing multiple vars.
402-
llvm::DenseMap<PatternBindingDecl *, TypeRefinementContext *>
403-
PatternBindingContexts;
404-
405391
TypeRefinementContext *getCurrentTRC() {
406392
return ContextStack.back().TRC;
407393
}
@@ -482,19 +468,9 @@ class TypeRefinementContextBuilder : private ASTWalker {
482468
PreWalkAction walkToDeclPre(Decl *D) override {
483469
PrettyStackTraceDecl trace(stackTraceAction(), D);
484470

485-
// Adds in a parent TRC for decls which are syntactically nested but are not
486-
// represented that way in the AST. (Particularly, AbstractStorageDecl
487-
// parents for AccessorDecl children.)
488-
if (auto ParentTRC = getEffectiveParentContextForDecl(D)) {
489-
pushContext(ParentTRC, D);
490-
}
491-
492471
// Adds in a TRC that covers the entire declaration.
493472
if (auto DeclTRC = getNewContextForSignatureOfDecl(D)) {
494473
pushContext(DeclTRC, D);
495-
496-
// Possibly use this as an effective parent context later.
497-
recordEffectiveParentContext(D, DeclTRC);
498474
}
499475

500476
// Create TRCs that cover only the body of the declaration.
@@ -515,49 +491,6 @@ class TypeRefinementContextBuilder : private ASTWalker {
515491
return Action::Continue();
516492
}
517493

518-
TypeRefinementContext *getEffectiveParentContextForDecl(Decl *D) {
519-
// FIXME: Can we assert that we won't walk parent decls later that should
520-
// have been returned here?
521-
if (auto *accessor = dyn_cast<AccessorDecl>(D)) {
522-
// Use TRC of the storage rather the current TRC when walking this
523-
// function.
524-
auto it = StorageContexts.find(accessor->getStorage());
525-
if (it != StorageContexts.end()) {
526-
return it->second;
527-
}
528-
} else if (auto *VD = dyn_cast<VarDecl>(D)) {
529-
// Use the TRC of the pattern binding decl as the parent for var decls.
530-
if (auto *PBD = VD->getParentPatternBinding()) {
531-
auto it = PatternBindingContexts.find(PBD);
532-
if (it != PatternBindingContexts.end()) {
533-
return it->second;
534-
}
535-
}
536-
}
537-
538-
return nullptr;
539-
}
540-
541-
/// If necessary, records a TRC so it can be returned by subsequent calls to
542-
/// `getEffectiveParentContextForDecl()`.
543-
void recordEffectiveParentContext(Decl *D, TypeRefinementContext *NewTRC) {
544-
if (auto *StorageDecl = dyn_cast<AbstractStorageDecl>(D)) {
545-
// Stash the TRC for the storage declaration to use as the parent of
546-
// accessor decls later.
547-
if (StorageDecl->hasParsedAccessors())
548-
StorageContexts[StorageDecl] = NewTRC;
549-
}
550-
551-
if (auto *VD = dyn_cast<VarDecl>(D)) {
552-
// Stash the TRC for the var decl if its parent pattern binding decl has
553-
// more than one entry so that the sibling var decls can reuse it.
554-
if (auto *PBD = VD->getParentPatternBinding()) {
555-
if (PBD->getNumPatternEntries() > 1)
556-
PatternBindingContexts[PBD] = NewTRC;
557-
}
558-
}
559-
}
560-
561494
/// Returns a new context to be introduced for the declaration, or nullptr
562495
/// if no new context should be introduced.
563496
TypeRefinementContext *getNewContextForSignatureOfDecl(Decl *D) {

0 commit comments

Comments
 (0)