================
@@ -93,14 +99,43 @@ void UseStdMoveCheck::check(const MatchFinder::MatchResult
&Result) {
if (!TheCFG)
return;
- // Walk the CFG bottom-up, starting with the exit node.
- // TODO: traverse the whole CFG instead of only considering terminator
- // nodes.
+ // The algorithm to look for a convertible move-assign operator is the
+ // following: each node starts in the `Ready` state, with a number of
+ // `RemainingSuccessors` equal to its number of successors.
+ //
+ // Starting from the exit node, we walk the CFG backward. Whenever
+ // we meet a new block, we check if it either:
+ // 1. touches the `AssignValue`, in which case we stop the search, and mark
+ // each
+ // predecessor as not `Ready`. No predecessor walk.
+ // 2. contains a convertible copy-assign operator, in which case we generate
a
+ // fix, and mark each predecessor as not Ready. No predecessor walk.
+ // 3. does not interact with `AssignValue`, in which case we decrement the
+ // `RemainingSuccessors` of each predecessor. And if it happens to turn to
+ // 0 while still being `Ready`, we add it to the `WorkList`.
+
+ struct BlockState {
+ bool Ready;
+ unsigned RemainingSuccessors;
+ };
+ std::unordered_map<const CFGBlock *, BlockState> CFGState;
----------------
zeyi2 wrote:
Can we use `llvm::DenseMap` for this?
In [Coding
Standard](https://llvm.org/docs/CodingStandards.html#c-standard-library):
> When both C++ and the LLVM support libraries provide similar functionality,
> and there isn’t a specific reason to favor the C++ implementation, it is
> generally preferable to use the LLVM library. For example, llvm::DenseMap
> should almost always be used instead of std::map or std::unordered_map, and
> llvm::SmallVector should usually be used instead of std::vector.
https://github.com/llvm/llvm-project/pull/184136
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits