================
@@ -641,6 +641,14 @@ void UseAfterMoveCheck::check(const
MatchFinder::MatchResult &Result) {
const CXXRecordDecl *MovedAs =
ParentCast ? ParentCast->getType()->getAsCXXRecordDecl() : nullptr;
+ if (!MovedAs && CallMove && CallMove->getNumArgs() > 0) {
+ if (const auto *ArgCast =
+ dyn_cast<ImplicitCastExpr>(CallMove->getArg(0)->IgnoreParens())) {
+ if (ArgCast->getCastKind() == CK_DerivedToBase)
+ MovedAs = ArgCast->getType()->getAsCXXRecordDecl();
+ }
+ }
----------------
voyager-jhk wrote:
> Instead of `if`'s here I think we can directly match this patter in matchers,
> something like:
>
> ```c++
> // this part already exist
> optionally(anyOf(
>
> hasParent(implicitCastExpr(hasCastKind(CK_DerivedToBase))
>
> .bind("optional-cast")),
>
> traverse(TK_AsIs, // maybe this traverse call is not needed, please
> check
>
> hasArgument(0, implicitCastExpr(hasCastKind(CK_DerivedToBase))
> .bind("optional-cast")))))
> ```
>
> So we won't need any new code in `check()` here
I tried that before, but it failed. I'll give it another shot.
https://github.com/llvm/llvm-project/pull/199905
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits