Skip to content

Conversation

@rniwa
Copy link
Contributor

@rniwa rniwa commented Feb 7, 2025

Implicit value initialization is trivial for our purposes.

Implicit value initialization is trivial for our purposes.
@rniwa rniwa requested a review from t-rasmud February 7, 2025 08:32
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:static analyzer labels Feb 7, 2025
@rniwa rniwa requested a review from haoNoQ February 7, 2025 08:32
@llvmbot
Copy link
Member

llvmbot commented Feb 7, 2025

@llvm/pr-subscribers-clang-static-analyzer-1

@llvm/pr-subscribers-clang

Author: Ryosuke Niwa (rniwa)

Changes

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 --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

double x;
double y;
};
void trivial68() { point pt = { 1.0 }; }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how much this matters for the test, but doesn't this leave y uninitialized?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It implicitly initializes y. That's what this bug is about. I wasn't recognizing that type of implicit initialization.

Copy link
Contributor

@t-rasmud t-rasmud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@rniwa
Copy link
Contributor Author

rniwa commented Feb 11, 2025

Thank you for the review!

@rniwa rniwa merged commit 595195e into llvm:main Feb 11, 2025
11 checks passed
@rniwa rniwa deleted the trivial-implicit-value-init branch February 11, 2025 04:40
rniwa added a commit to rniwa/llvm-project that referenced this pull request Feb 11, 2025
…lvm#126203)

Implicit value initialization is trivial for our purposes.
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
…lvm#126203)

Implicit value initialization is trivial for our purposes.
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
…lvm#126203)

Implicit value initialization is trivial for our purposes.
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
…lvm#126203)

Implicit value initialization is trivial for our purposes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:static analyzer clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants