[clang] [mutation analyzer] support mutation analysis for pointee (PR #118593)
Julian Schmidt via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 21 01:03:27 PST 2025
================
@@ -654,6 +716,83 @@ ExprMutationAnalyzer::Analyzer::findFunctionArgMutation(const Expr *Exp) {
return nullptr;
}
+const Stmt *
+ExprMutationAnalyzer::Analyzer::findPointeeValueMutation(const Expr *Exp) {
+ const auto Matches = match(
+ stmt(forEachDescendant(
+ expr(anyOf(
+ // deref by *
+ unaryOperator(hasOperatorName("*"),
+ hasUnaryOperand(canResolveToExprPointee(Exp))),
+ // deref by []
+ arraySubscriptExpr(hasBase(canResolveToExprPointee(Exp)))))
+ .bind(NodeID<Expr>::value))),
+ Stm, Context);
+ return findExprMutation(Matches);
+}
+
+const Stmt *
+ExprMutationAnalyzer::Analyzer::findPointeeMemberMutation(const Expr *Exp) {
+ const Stmt *MemberCallExpr = selectFirst<Stmt>(
+ "stmt", match(stmt(forEachDescendant(
+ cxxMemberCallExpr(on(canResolveToExprPointee(Exp)),
+ unless(isConstCallee()))
----------------
5chmidti wrote:
Please check for the constness of the callee before trying to resolve to `Exp`
https://github.com/llvm/llvm-project/pull/118593
More information about the cfe-commits
mailing list