File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -235,6 +235,11 @@ class ASTWalker {
235235 // / until eventually we can remove this altogether.
236236 virtual bool shouldWalkAccessorsTheOldWay () { return false ; }
237237
238+ // / Whether to walk internal top level decls in serialized modules.
239+ // /
240+ // / TODO: Consider changing this to false by default.
241+ virtual bool shouldWalkSerializedTopLevelInternalDecls () { return true ; }
242+
238243 // / walkToParameterListPre - This method is called when first visiting a
239244 // / ParameterList, before walking into its parameters. If it returns false,
240245 // / the subtree is skipped.
Original file line number Diff line number Diff line change @@ -2916,7 +2916,17 @@ bool FileUnit::walk(ASTWalker &walker) {
29162916 getTopLevelDecls (Decls);
29172917 llvm::SaveAndRestore<ASTWalker::ParentTy> SAR (walker.Parent ,
29182918 getParentModule ());
2919+
2920+ bool SkipInternal = getKind () == FileUnitKind::SerializedAST &&
2921+ !walker.shouldWalkSerializedTopLevelInternalDecls ();
29192922 for (Decl *D : Decls) {
2923+ if (SkipInternal) {
2924+ if (auto *VD = dyn_cast<ValueDecl>(D)) {
2925+ if (!VD->isAccessibleFrom (nullptr ))
2926+ continue ;
2927+ }
2928+ }
2929+
29202930#ifndef NDEBUG
29212931 PrettyStackTraceDecl debugStack (" walking into decl" , D);
29222932#endif
Original file line number Diff line number Diff line change @@ -54,6 +54,11 @@ class SemaAnnotator : public ASTWalker {
5454 bool shouldWalkIntoGenericParams () override {
5555 return SEWalker.shouldWalkIntoGenericParams ();
5656 }
57+
58+ bool shouldWalkSerializedTopLevelInternalDecls () override {
59+ return false ;
60+ }
61+
5762 bool walkToDeclPre (Decl *D) override ;
5863 bool walkToDeclPreProper (Decl *D);
5964 std::pair<bool , Expr *> walkToExprPre (Expr *E) override ;
You can’t perform that action at this time.
0 commit comments