@@ -540,7 +540,7 @@ bool SwiftASTManipulator::RewriteResult() {
540
540
// First step, walk the function body converting returns to assignments to
541
541
// temp variables + return:
542
542
543
- for (swift::Decl *decl : m_source_file.Decls ) {
543
+ for (swift::Decl *decl : m_source_file.getTopLevelDecls () ) {
544
544
if (auto top_level_code_decl =
545
545
llvm::dyn_cast<swift::TopLevelCodeDecl>(decl)) {
546
546
return_finder.SetDeclContext (top_level_code_decl);
@@ -551,8 +551,8 @@ bool SwiftASTManipulator::RewriteResult() {
551
551
// Second step, fetch the last expression, and if it is non-null, set it to
552
552
// a temp result as well:
553
553
554
- if (!m_source_file.Decls .empty ()) {
555
- swift::Decl *last_decl = *(m_source_file.Decls .end () - 1 );
554
+ if (!m_source_file.getTopLevelDecls () .empty ()) {
555
+ swift::Decl *last_decl = *(m_source_file.getTopLevelDecls () .end () - 1 );
556
556
557
557
if (auto last_top_level_code_decl =
558
558
llvm::dyn_cast<swift::TopLevelCodeDecl>(last_decl)) {
@@ -707,7 +707,7 @@ void SwiftASTManipulator::FindVariableDeclarations(
707
707
};
708
708
709
709
if (m_repl) {
710
- for (swift::Decl *decl : m_source_file.Decls ) {
710
+ for (swift::Decl *decl : m_source_file.getTopLevelDecls () ) {
711
711
if (swift::VarDecl *var_decl = llvm::dyn_cast<swift::VarDecl>(decl)) {
712
712
if (!var_decl->getName ().str ().startswith (" $" )) {
713
713
register_one_var (var_decl);
@@ -750,7 +750,7 @@ void SwiftASTManipulator::FindNonVariableDeclarations(
750
750
if (!m_repl)
751
751
return ; // we don't do this for non-REPL expressions... yet
752
752
753
- for (swift::Decl *decl : m_source_file.Decls ) {
753
+ for (swift::Decl *decl : m_source_file.getTopLevelDecls () ) {
754
754
if (swift::ValueDecl *value_decl = llvm::dyn_cast<swift::ValueDecl>(decl)) {
755
755
if (!llvm::isa<swift::VarDecl>(value_decl) && value_decl->hasName ()) {
756
756
non_variables.push_back (value_decl);
@@ -1078,9 +1078,8 @@ bool SwiftASTManipulator::AddExternalVariables(
1078
1078
1079
1079
redirected_var_decl->setImplicit (true );
1080
1080
1081
- m_source_file.Decls .insert (m_source_file.Decls .begin (), top_level_code);
1082
- m_source_file.Decls .insert (m_source_file.Decls .begin (),
1083
- redirected_var_decl);
1081
+ m_source_file.addTopLevelDecl (top_level_code);
1082
+ m_source_file.addTopLevelDecl (redirected_var_decl);
1084
1083
1085
1084
variable.m_decl = redirected_var_decl;
1086
1085
@@ -1355,7 +1354,7 @@ swift::ValueDecl *SwiftASTManipulator::MakeGlobalTypealias(
1355
1354
if (make_private) {
1356
1355
type_alias_decl->overwriteAccess (swift::AccessLevel::Private);
1357
1356
}
1358
- m_source_file.Decls . push_back (type_alias_decl);
1357
+ m_source_file.addTopLevelDecl (type_alias_decl);
1359
1358
}
1360
1359
1361
1360
return type_alias_decl;
0 commit comments