mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Refactoring] Fix stack-use-after-scope in ContextFinder
Storing `llvm::function_ref` as a member field is not safe. Just use std::function instead. rdar://103369305
This commit is contained in:
@@ -49,7 +49,7 @@ class ContextFinder : public SourceEntityWalker {
|
||||
ASTContext &Ctx;
|
||||
SourceManager &SM;
|
||||
SourceRange Target;
|
||||
function_ref<bool(ASTNode)> IsContext;
|
||||
std::function<bool(ASTNode)> IsContext;
|
||||
SmallVector<ASTNode, 4> AllContexts;
|
||||
bool contains(ASTNode Enclosing) {
|
||||
auto Result = SM.rangeContains(Enclosing.getSourceRange(), Target);
|
||||
@@ -59,12 +59,12 @@ class ContextFinder : public SourceEntityWalker {
|
||||
}
|
||||
public:
|
||||
ContextFinder(SourceFile &SF, ASTNode TargetNode,
|
||||
function_ref<bool(ASTNode)> IsContext =
|
||||
std::function<bool(ASTNode)> IsContext =
|
||||
[](ASTNode N) { return true; }) :
|
||||
SF(SF), Ctx(SF.getASTContext()), SM(Ctx.SourceMgr),
|
||||
Target(TargetNode.getSourceRange()), IsContext(IsContext) {}
|
||||
ContextFinder(SourceFile &SF, SourceLoc TargetLoc,
|
||||
function_ref<bool(ASTNode)> IsContext =
|
||||
std::function<bool(ASTNode)> IsContext =
|
||||
[](ASTNode N) { return true; }) :
|
||||
SF(SF), Ctx(SF.getASTContext()), SM(Ctx.SourceMgr),
|
||||
Target(TargetLoc), IsContext(IsContext) {
|
||||
|
||||
Reference in New Issue
Block a user