[llvm-branch-commits] [clang] [SSAF][SourceTransformation] Add transformation for new[] and malloc (PR #223274)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sun Sep 13 14:11:46 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- clang/lib/ScalableStaticAnalysis/SourceTransformation/Transformations/CppBoundedBuffers.cpp clang/unittests/ScalableStaticAnalysis/SourceTransformation/CppBoundedBuffersTest.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/ScalableStaticAnalysis/SourceTransformation/Transformations/CppBoundedBuffers.cpp b/clang/lib/ScalableStaticAnalysis/SourceTransformation/Transformations/CppBoundedBuffers.cpp
index e4f9c511a..cb8591ee7 100644
--- a/clang/lib/ScalableStaticAnalysis/SourceTransformation/Transformations/CppBoundedBuffers.cpp
+++ b/clang/lib/ScalableStaticAnalysis/SourceTransformation/Transformations/CppBoundedBuffers.cpp
@@ -1137,7 +1137,7 @@ bool ExpressionRewriter::addEditToAtomicChange(
return AC.replace(SM, FileRange, NewText);
case InsertAtBegin:
return AC.insert(SM, FileRange.getBegin(), NewText,
- /*InsertAfter=*/false);
+ /*InsertAfter=*/false);
case InsertAtEnd:
return AC.insert(SM, FileRange.getEnd(), NewText, /*InsertAfter=*/true);
}
diff --git a/clang/unittests/ScalableStaticAnalysis/SourceTransformation/CppBoundedBuffersTest.cpp b/clang/unittests/ScalableStaticAnalysis/SourceTransformation/CppBoundedBuffersTest.cpp
index 74487af55..ace2a67f1 100644
--- a/clang/unittests/ScalableStaticAnalysis/SourceTransformation/CppBoundedBuffersTest.cpp
+++ b/clang/unittests/ScalableStaticAnalysis/SourceTransformation/CppBoundedBuffersTest.cpp
@@ -964,12 +964,12 @@ TEST_F(CppBoundedBuffersTest, RHSNewArrayMacroSizeExprRewritten) {
// rewrite would land only the closing ')' without ever inserting the
// 'bounded_ptr<int>::_new(' prefix.
StringRef Code = "#define HALF 9\n"
- "void g() { int *p = new int[HALF + 1]; }\n";
+ "void g() { int *p = new int[HALF + 1]; }\n";
Captured C =
run(Code, [](ASTContext &Ctx) { return varEntity("p", Ctx); }, {1});
EXPECT_EQ(C.Rewritten, "#define HALF 9\n"
- "void g() { bounded_ptr<int> p = "
- "bounded_ptr<int>::_new(HALF + 1); }\n");
+ "void g() { bounded_ptr<int> p = "
+ "bounded_ptr<int>::_new(HALF + 1); }\n");
EXPECT_TRUE(C.Reports.empty());
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/223274
More information about the llvm-branch-commits
mailing list