[clang-tools-extra] [clang-tidy] Fixed a false positive for pointer parameters used as placement-new storage (PR #207770)

Yanzuo Liu via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 10 22:03:34 PDT 2026


================
@@ -94,6 +94,9 @@ void NonConstParameterCheck::check(const MatchFinder::MatchResult &Result) {
           markCanNotBeConst(Arg->IgnoreParenCasts(), false);
         }
       }
+    } else if (const auto *NE = dyn_cast<CXXNewExpr>(S)) {
+      for (const auto *Arg : NE->placement_arguments())
+        markCanNotBeConst(Arg->IgnoreParenCasts(), true);
----------------
zwuis wrote:

We should handle this like handling `CallExpr` or `CXXConstructExpr`.

```cpp
// in clang ASTContext.h, omitting parameter names
void *operator new(size_t, const ASTContext &, size_t);
//                         ^ arguments can be const here
```

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


More information about the cfe-commits mailing list