================
@@ -150,6 +165,61 @@ makeReinitMatcher(const ValueDecl *MovedVariable,
.bind("reinit");
}
+static bool
+isVariableResetInLambda(const Stmt *Body, const ValueDecl *MovedVariable,
+ ASTContext *Context,
+ llvm::ArrayRef<StringRef> InvalidationFunctions) {
+ assert(Body && "There should be a lambda body");
+
+ // If the variable is not mentioned at all in the lambda body,
+ // it cannot be reinitialized.
+ const auto VariableMentionMatcher = stmt(anyOf(
+ hasDescendant(declRefExpr(hasDeclaration(equalsNode(MovedVariable)))),
+ hasDescendant(memberExpr(hasDeclaration(equalsNode(MovedVariable))))));
+
+ if (match(VariableMentionMatcher, *Body, *Context).empty())
+ return false;
+
+ CFG::BuildOptions Options;
----------------
zeyi2 wrote:
I'm not sure whether there is a better way to do this. It seems that the CFG
built by `UseAfterMoveFinder::find` doesn't contain information inside the
Lambda body.
Also I find it hard to inline the lambda's CFG into the parent's CFG, so I
choose to build a separate one to detect unreachable reinitializations.
https://github.com/llvm/llvm-project/pull/173192
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits