File tree Expand file tree Collapse file tree 6 files changed +18
-4
lines changed Expand file tree Collapse file tree 6 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -791,6 +791,10 @@ class ASTContext final {
791
791
// / \param IDC The context whose member decls should be lazily parsed.
792
792
void parseMembers (IterableDeclContext *IDC);
793
793
794
+ // / Use the lazy parsers associated with the context to check whether the decl
795
+ // / context has been parsed.
796
+ bool hasUnparsedMembers (const IterableDeclContext *IDC) const ;
797
+
794
798
// / Get the lazy function data for the given generic context.
795
799
// /
796
800
// / \param lazyLoader If non-null, the lazy loader to use when creating the
Original file line number Diff line number Diff line change @@ -101,6 +101,9 @@ class LazyMemberParser {
101
101
// /
102
102
// / The implementation should add the members to IDC.
103
103
virtual void parseMembers (IterableDeclContext *IDC) = 0;
104
+
105
+ // / Return whether the iterable decl context needs parsing.
106
+ virtual bool hasUnparsedMembers (const IterableDeclContext *IDC) = 0;
104
107
};
105
108
106
109
// / Context data for generic contexts.
Original file line number Diff line number Diff line change @@ -174,7 +174,7 @@ class PersistentParserState: public LazyMemberParser {
174
174
std::unique_ptr<DelayedDeclListState>
175
175
takeDelayedDeclListState (IterableDeclContext *IDC);
176
176
177
- bool hasDelayedDeclList ( IterableDeclContext *IDC) {
177
+ bool hasUnparsedMembers ( const IterableDeclContext *IDC) override {
178
178
return DelayedDeclListStates.find (IDC) != DelayedDeclListStates.end ();
179
179
}
180
180
Original file line number Diff line number Diff line change @@ -1903,9 +1903,16 @@ LazyContextData *ASTContext::getOrCreateLazyContextData(
1903
1903
return contextData;
1904
1904
}
1905
1905
1906
+ bool ASTContext::hasUnparsedMembers (const IterableDeclContext *IDC) const {
1907
+ auto parsers = getImpl ().lazyParsers ;
1908
+ return std::any_of (parsers.begin (), parsers.end (),
1909
+ [IDC](LazyMemberParser *p) { return p->hasUnparsedMembers (IDC); });
1910
+ }
1911
+
1906
1912
void ASTContext::parseMembers (IterableDeclContext *IDC) {
1907
1913
for (auto *p: getImpl ().lazyParsers ) {
1908
- p->parseMembers (IDC);
1914
+ if (p->hasUnparsedMembers (IDC))
1915
+ p->parseMembers (IDC);
1909
1916
}
1910
1917
}
1911
1918
Original file line number Diff line number Diff line change @@ -709,6 +709,8 @@ class Verifier : public ASTWalker {
709
709
pushScope (fn); \
710
710
if (fn->hasLazyMembers ()) \
711
711
return false ; \
712
+ if (fn->getASTContext ().hasUnparsedMembers (fn)) \
713
+ return false ; \
712
714
return shouldVerify (cast<ASTNodeBase<NODE*>::BaseTy>(fn));\
713
715
} \
714
716
void cleanup (NODE *fn) { \
Original file line number Diff line number Diff line change @@ -181,8 +181,6 @@ namespace {
181
181
} // end anonymous namespace
182
182
183
183
void PersistentParserState::parseMembers (IterableDeclContext *IDC) {
184
- if (!hasDelayedDeclList (IDC))
185
- return ;
186
184
SourceFile &SF = *IDC->getDecl ()->getDeclContext ()->getParentSourceFile ();
187
185
assert (!SF.hasInterfaceHash () &&
188
186
" Cannot delay parsing if we care about the interface hash." );
You can’t perform that action at this time.
0 commit comments