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 {
235
235
// / until eventually we can remove this altogether.
236
236
virtual bool shouldWalkAccessorsTheOldWay () { return false ; }
237
237
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
+
238
243
// / walkToParameterListPre - This method is called when first visiting a
239
244
// / ParameterList, before walking into its parameters. If it returns false,
240
245
// / the subtree is skipped.
Original file line number Diff line number Diff line change @@ -2916,7 +2916,17 @@ bool FileUnit::walk(ASTWalker &walker) {
2916
2916
getTopLevelDecls (Decls);
2917
2917
llvm::SaveAndRestore<ASTWalker::ParentTy> SAR (walker.Parent ,
2918
2918
getParentModule ());
2919
+
2920
+ bool SkipInternal = getKind () == FileUnitKind::SerializedAST &&
2921
+ !walker.shouldWalkSerializedTopLevelInternalDecls ();
2919
2922
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
+
2920
2930
#ifndef NDEBUG
2921
2931
PrettyStackTraceDecl debugStack (" walking into decl" , D);
2922
2932
#endif
Original file line number Diff line number Diff line change @@ -54,6 +54,11 @@ class SemaAnnotator : public ASTWalker {
54
54
bool shouldWalkIntoGenericParams () override {
55
55
return SEWalker.shouldWalkIntoGenericParams ();
56
56
}
57
+
58
+ bool shouldWalkSerializedTopLevelInternalDecls () override {
59
+ return false ;
60
+ }
61
+
57
62
bool walkToDeclPre (Decl *D) override ;
58
63
bool walkToDeclPreProper (Decl *D);
59
64
std::pair<bool , Expr *> walkToExprPre (Expr *E) override ;
You can’t perform that action at this time.
0 commit comments