llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Berkay Sahin (berkaysahiin) <details> <summary>Changes</summary> Fixes #<!-- -->187012 which is a false positive on clang-tidy end. --- Full diff: https://github.com/llvm/llvm-project/pull/187508.diff 2 Files Affected: - (modified) clang/lib/Analysis/ExprMutationAnalyzer.cpp (+2) - (modified) clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp (+9) ``````````diff diff --git a/clang/lib/Analysis/ExprMutationAnalyzer.cpp b/clang/lib/Analysis/ExprMutationAnalyzer.cpp index 86d7dcab807d3..5def6ba3cac5a 100644 --- a/clang/lib/Analysis/ExprMutationAnalyzer.cpp +++ b/clang/lib/Analysis/ExprMutationAnalyzer.cpp @@ -787,6 +787,8 @@ ExprMutationAnalyzer::Analyzer::findPointeeToNonConst(const Expr *Exp) { anyOf(ArgOfNonConstParameter, ArgOfInstantiationDependent); const auto PassAsNonConstArg = expr(anyOf(cxxUnresolvedConstructExpr(ArgOfInstantiationDependent), + cxxNewExpr(hasAnyPlacementArg( + ignoringParenImpCasts(canResolveToExprPointee(Exp)))), cxxConstructExpr(CallLikeMatcher), callExpr(CallLikeMatcher), parenListExpr(has(canResolveToExprPointee(Exp))), initListExpr(hasAnyInit(canResolveToExprPointee(Exp))))); diff --git a/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp b/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp index d171d47ac1fef..27c0be6b74fcc 100644 --- a/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp +++ b/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp @@ -1801,6 +1801,15 @@ TEST(ExprMutationAnalyzerTest, PointeeMutatedByPassAsArgument) { match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); EXPECT_TRUE(isPointeeMutated(Results, AST.get())); } + { + const std::string Code = + "void* operator new(unsigned long, void* p) noexcept;" + "void f() { int* x = nullptr; new(x) int{311}; }"; + auto AST = buildASTFromCodeWithArgs(Code, {}); + auto Results = + match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); + EXPECT_TRUE(isPointeeMutated(Results, AST.get())); + } } TEST(ExprMutationAnalyzerTest, PointeeMutatedByPassAsArgumentInConstruct) { `````````` </details> https://github.com/llvm/llvm-project/pull/187508 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
