================
@@ -175,6 +218,10 @@ bool UseAfterMoveFinder::findInternal(const CFGBlock 
*Block,
             MovingCall != nullptr &&
             Sequence->potentiallyAfter(MovingCall, Use);
 
+        // We default to false here and change this to true if required in
+        // find().
+        TheUseAfterMove->UseHappensInLaterLoopIteration = false;
+
----------------
tchaikov wrote:

agreed. but practically, we reference `EvaluationOrderUndefined` only if 
`UseAfterMoveFinder::find()` returns `true`, which indicates a use-after-move 
is identified. see 
https://github.com/llvm/llvm-project/blob/4d95850d052336a785651030eafa0b24651801a0/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp#L498-L501,
 and the only two places where we return `true` in 
`UseAfterMoveFinder::findInternal()` are

1. 
https://github.com/llvm/llvm-project/blob/4d95850d052336a785651030eafa0b24651801a0/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp#L178
2. 
https://github.com/llvm/llvm-project/blob/4d95850d052336a785651030eafa0b24651801a0/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp#L188

the 2nd case is a recursive call to `UseAfterMoveFinder::findInternal()`. and 
the 1st case is where we set `UseHappensInLaterLoopIteration` to `false`. and 
we may set this member variable to `true` later on.

probably a more readable implementation is to return an 
`optional<UseAfterMove>` from `UseAfterMoveFinder::find()`, so that it's 
obvious that `UseAfterMove` is always initialized and returned if we find a 
use-after-move. but that'd be a cleanup, and not directly related to this PR. 
if it acceptable to piggy back it into this PR, i will do it.

https://github.com/llvm/llvm-project/pull/93623
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to