[clang] [clang] Detect pointee mutations in placement new expressions (PR #187508)

Berkay Sahin via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 20 05:08:14 PDT 2026


================
@@ -1801,6 +1801,16 @@ TEST(ExprMutationAnalyzerTest, PointeeMutatedByPassAsArgument) {
         match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
     EXPECT_TRUE(isPointeeMutated(Results, AST.get()));
   }
+  {
+    const std::string Code =
+        "namespace std { typedef decltype(sizeof(int)) size_t; }"
----------------
berkaysahiin wrote:

> Do we really need size_t define here? can we just use plain `unsigned int` or `int`?

Neither of these seems to be compiling: https://godbolt.org/z/5e9fEejxW

Other tests seems to be using the same approach we use here,  for instance `clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp : 2406` so this is pretty much identical to those.

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


More information about the cfe-commits mailing list