Skip to content

[Clang] Add non static data member initializer for BindingDecl member Decomp #134969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2025

Conversation

shafik
Copy link
Collaborator

@shafik shafik commented Apr 9, 2025

Static analysis flagged BindingDecl Decomp member as not being initialized during construction or by any other member function.

Fix is add a default initializer for it like the other member Binding.

… Decomp

Static analysis flagged BindingDecl Decomp member as not being initialized
during construction or by any other member function.

Fix is add a default initializer for it like the other member Binding.
@shafik shafik added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Apr 9, 2025
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Apr 9, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 9, 2025

@llvm/pr-subscribers-clang

Author: Shafik Yaghmour (shafik)

Changes

Static analysis flagged BindingDecl Decomp member as not being initialized during construction or by any other member function.

Fix is add a default initializer for it like the other member Binding.


Full diff: https://github.com/llvm/llvm-project/pull/134969.diff

1 Files Affected:

  • (modified) clang/include/clang/AST/DeclCXX.h (+1-1)
diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h
index 56cec07ec0293..f0e25c4105f87 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -4166,7 +4166,7 @@ class StaticAssertDecl : public Decl {
 /// DecompositionDecl of type 'int (&)[3]'.
 class BindingDecl : public ValueDecl {
   /// The declaration that this binding binds to part of.
-  ValueDecl *Decomp;
+  ValueDecl *Decomp = nullptr;
   /// The binding represented by this declaration. References to this
   /// declaration are effectively equivalent to this expression (except
   /// that it is only evaluated once at the point of declaration of the

Copy link
Contributor

@zyn0217 zyn0217 left a comment

Choose a reason for hiding this comment

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

... or by any other member function

It should be initialized by setDecomposedDecl() - but this change doesn't hurt so LGTM

@shafik shafik merged commit 12b1ed2 into llvm:main Apr 9, 2025
14 checks passed
AllinLeeYL pushed a commit to AllinLeeYL/llvm-project that referenced this pull request Apr 10, 2025
… Decomp (llvm#134969)

Static analysis flagged BindingDecl Decomp member as not being
initialized during construction or by any other member function.

Fix is add a default initializer for it like the other member Binding.
@shafik shafik deleted the add_nsmdi_for_decomp_bindingdecl branch April 10, 2025 21:35
var-const pushed a commit to ldionne/llvm-project that referenced this pull request Apr 17, 2025
… Decomp (llvm#134969)

Static analysis flagged BindingDecl Decomp member as not being
initialized during construction or by any other member function.

Fix is add a default initializer for it like the other member Binding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants