[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:25 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) {
----------------
5chmidti wrote:

A `CXXOperatorCallExpr` could mutate as well, e.g., `(), +=`

https://github.com/llvm/llvm-project/pull/118593


More information about the cfe-commits mailing list