Skip to content

Commit 1af9357

Browse files
authored
Merge pull request #5238 from hamishknight/walk-this-way
2 parents fecabcd + da525b2 commit 1af9357

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

lldb/source/Plugins/ExpressionParser/Swift/SwiftASTManipulator.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -267,26 +267,26 @@ void SwiftASTManipulatorBase::DoInitialization() {
267267
/// This is an optional extension holding the above function.
268268
swift::ExtensionDecl *extension_decl = nullptr;
269269

270-
bool walkToDeclPre(swift::Decl *D) override {
270+
PreWalkAction walkToDeclPre(swift::Decl *D) override {
271271
auto *FD = llvm::dyn_cast<swift::FuncDecl>(D);
272272
// Traverse into any non-function-decls.
273273
if (!FD)
274-
return true;
274+
return Action::Continue();
275275

276276
if (!FD->getAttrs().hasAttribute<swift::LLDBDebuggerFunctionAttr>())
277-
return false;
277+
return Action::SkipChildren();
278278

279279
// Walk up the DeclContext chain, searching for an extension.
280280
for (auto *DC = FD->getDeclContext(); DC; DC = DC->getParent()) {
281281
if (auto *extension = llvm::dyn_cast<swift::ExtensionDecl>(DC)) {
282282
extension_decl = extension;
283283
ext_method_decl = FD;
284-
return false;
284+
return Action::SkipChildren();
285285
}
286286
}
287287
// Not in an extenstion,
288288
toplevel_decl = FD;
289-
return false;
289+
return Action::SkipChildren();
290290
}
291291
};
292292

@@ -354,15 +354,15 @@ void SwiftASTManipulator::FindSpecialNames(
354354
SpecialNameFinder(NameVector &names, llvm::StringRef &prefix)
355355
: m_names(names), m_prefix(prefix) {}
356356

357-
std::pair<bool, swift::Expr *> walkToExprPre(swift::Expr *E) override {
357+
PreWalkResult<swift::Expr *> walkToExprPre(swift::Expr *E) override {
358358
if (auto *UDRE = llvm::dyn_cast<swift::UnresolvedDeclRefExpr>(E)) {
359359
swift::Identifier name = UDRE->getName().getBaseIdentifier();
360360

361361
if (m_prefix.empty() || name.str().startswith(m_prefix))
362362
m_names.push_back(name);
363363
}
364364

365-
return {true, E};
365+
return Action::Continue(E);
366366
}
367367

368368
private:
@@ -476,44 +476,44 @@ bool SwiftASTManipulator::RewriteResult() {
476476
m_decl_context = decl_context;
477477
}
478478

479-
bool walkToDeclPre(swift::Decl *D) override {
479+
PreWalkAction walkToDeclPre(swift::Decl *D) override {
480480
switch (D->getKind()) {
481-
default: return true;
481+
default: return Action::Continue();
482482

483483
// Don't step into function declarations, they may have returns, but we
484484
// don't want to instrument them.
485485
case swift::DeclKind::Accessor:
486486
case swift::DeclKind::Func:
487487
case swift::DeclKind::Class:
488488
case swift::DeclKind::Struct:
489-
return false;
489+
return Action::SkipChildren();
490490
}
491491
}
492492

493-
std::pair<bool, swift::Expr *> walkToExprPre(swift::Expr *expr) override {
493+
PreWalkResult<swift::Expr *> walkToExprPre(swift::Expr *expr) override {
494494
switch (expr->getKind()) {
495-
default: return {true, expr};
495+
default: return Action::Continue(expr);
496496

497497
// Don't step into closure definitions, they may have returns, but we
498498
// don't want to instrument them either.
499499
case swift::ExprKind::Closure:
500-
return {false, expr};
500+
return Action::SkipChildren(expr);
501501
}
502502
}
503503

504-
swift::Stmt *walkToStmtPost(swift::Stmt *S) override {
504+
PostWalkResult<swift::Stmt *> walkToStmtPost(swift::Stmt *S) override {
505505
auto *RS = swift::dyn_cast<swift::ReturnStmt>(S);
506506
if (!RS || !RS->getResult())
507-
return S;
507+
return Action::Continue(S);
508508

509509
if (swift::Expr *RE = RS->getResult()) {
510510
if (swift::Stmt *S =
511511
m_manipulator.ConvertExpressionToTmpReturnVarAccess(
512512
RE, RS->getStartLoc(), /*add_return=*/true, m_decl_context))
513-
return S;
513+
return Action::Continue(S);
514514
}
515515

516-
return S;
516+
return Action::Continue(S);
517517
}
518518

519519
private:
@@ -629,9 +629,9 @@ void SwiftASTManipulator::MakeDeclarationsPublic() {
629629
return true;
630630
}
631631

632-
bool walkToDeclPre(swift::Decl *D) override {
632+
PreWalkAction walkToDeclPre(swift::Decl *D) override {
633633
if (!canMakePublic(D))
634-
return true;
634+
return Action::Continue();
635635

636636
if (auto *VD = llvm::dyn_cast<swift::ValueDecl>(D)) {
637637
auto access = swift::AccessLevel::Public;
@@ -650,7 +650,7 @@ void SwiftASTManipulator::MakeDeclarationsPublic() {
650650
if (auto *ASD = llvm::dyn_cast<swift::AbstractStorageDecl>(D))
651651
ASD->overwriteSetterAccess(access);
652652
}
653-
return true;
653+
return Action::Continue();
654654
}
655655
};
656656

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,14 +554,14 @@ namespace {
554554
class ASTVerifier : public swift::ASTWalker {
555555
bool hasMissingPatterns = false;
556556

557-
bool walkToDeclPre(swift::Decl *D) override {
557+
PreWalkAction walkToDeclPre(swift::Decl *D) override {
558558
if (auto *PBD = llvm::dyn_cast<swift::PatternBindingDecl>(D)) {
559559
if (PBD->getPatternList().empty()) {
560560
hasMissingPatterns = true;
561-
return false;
561+
return Action::SkipChildren();
562562
}
563563
}
564-
return true;
564+
return Action::Continue();
565565
}
566566

567567
public:

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8117,11 +8117,11 @@ bool SwiftASTContext::CacheUserImports(SwiftASTContext &swift_ast_context,
81178117
struct UserImportFinder : public swift::ASTWalker {
81188118
llvm::SmallDenseSet<swift::ModuleDecl*, 1> imports;
81198119

8120-
bool walkToDeclPre(swift::Decl *D) override {
8120+
PreWalkAction walkToDeclPre(swift::Decl *D) override {
81218121
if (auto *ID = llvm::dyn_cast<swift::ImportDecl>(D))
81228122
if (auto *M = ID->getModule())
81238123
imports.insert(M);
8124-
return true;
8124+
return Action::Continue();
81258125
}
81268126
};
81278127
UserImportFinder import_finder;

0 commit comments

Comments
 (0)