[clang] [WebKit checkers] Treat an implicit value initialization as trivial (PR #126203)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 7 00:32:39 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Ryosuke Niwa (rniwa)
<details>
<summary>Changes</summary>
Implicit value initialization is trivial for our purposes.
---
Full diff: https://github.com/llvm/llvm-project/pull/126203.diff
2 Files Affected:
- (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp (+5)
- (modified) clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp (+6)
``````````diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index 5487fea1b956c83..d40b4b4dbb5607a 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -636,6 +636,11 @@ class TrivialFunctionAnalysisVisitor
return true;
}
+ bool VisitImplicitValueInitExpr(const ImplicitValueInitExpr *IVIE) {
+ // An implicit value initialization is trvial.
+ return true;
+ }
+
private:
CacheTy &Cache;
CacheTy RecursiveFn;
diff --git a/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp b/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
index d654d963a4faeff..ffeecbf87c4516f 100644
--- a/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
@@ -368,6 +368,11 @@ class RefCounted {
}
RefPtr<RefCounted> trivial66() { return children[0]; }
Ref<RefCounted> trivial67() { return *children[0]; }
+ struct point {
+ double x;
+ double y;
+ };
+ void trivial68() { point pt = { 1.0 }; }
static RefCounted& singleton() {
static RefCounted s_RefCounted;
@@ -554,6 +559,7 @@ class UnrelatedClass {
getFieldTrivial().trivial65(); // no-warning
getFieldTrivial().trivial66()->trivial6(); // no-warning
getFieldTrivial().trivial67()->trivial6(); // no-warning
+ getFieldTrivial().trivial68(); // no-warning
RefCounted::singleton().trivial18(); // no-warning
RefCounted::singleton().someFunction(); // no-warning
``````````
</details>
https://github.com/llvm/llvm-project/pull/126203
More information about the cfe-commits
mailing list