Skip to content

Commit 25c4c99

Browse files
committed
[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
1 parent 10d131d commit 25c4c99

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/Refactoring/Refactoring.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ContextFinder : public SourceEntityWalker {
4949
ASTContext &Ctx;
5050
SourceManager &SM;
5151
SourceRange Target;
52-
function_ref<bool(ASTNode)> IsContext;
52+
std::function<bool(ASTNode)> IsContext;
5353
SmallVector<ASTNode, 4> AllContexts;
5454
bool contains(ASTNode Enclosing) {
5555
auto Result = SM.rangeContains(Enclosing.getSourceRange(), Target);
@@ -59,12 +59,12 @@ class ContextFinder : public SourceEntityWalker {
5959
}
6060
public:
6161
ContextFinder(SourceFile &SF, ASTNode TargetNode,
62-
function_ref<bool(ASTNode)> IsContext =
62+
std::function<bool(ASTNode)> IsContext =
6363
[](ASTNode N) { return true; }) :
6464
SF(SF), Ctx(SF.getASTContext()), SM(Ctx.SourceMgr),
6565
Target(TargetNode.getSourceRange()), IsContext(IsContext) {}
6666
ContextFinder(SourceFile &SF, SourceLoc TargetLoc,
67-
function_ref<bool(ASTNode)> IsContext =
67+
std::function<bool(ASTNode)> IsContext =
6868
[](ASTNode N) { return true; }) :
6969
SF(SF), Ctx(SF.getASTContext()), SM(Ctx.SourceMgr),
7070
Target(TargetLoc), IsContext(IsContext) {

0 commit comments

Comments
 (0)