Skip to content

[HLSL][NFC] Fix static analyzer concerns #120090

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 2 commits into from
Dec 17, 2024
Merged

Conversation

Fznamznon
Copy link
Contributor

Class BuiltinTypeMethodBuilder has a user-defined destructor so likely compiler generated special functions may behave incorrectly. Delete explicitly copy constructor and copy assignment operator to avoid potential errors.

Class BuiltinTypeMethodBuilder has a user-defined destructor so likely
compiler generated special functions may behave incorrectly. Delete
explicitly copy constructor and copy assignment operator to avoid
potential errors.
@Fznamznon Fznamznon requested review from bogner and hekota December 16, 2024 14:33
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" HLSL HLSL Language Support labels Dec 16, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 16, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-hlsl

Author: Mariya Podchishchaeva (Fznamznon)

Changes

Class BuiltinTypeMethodBuilder has a user-defined destructor so likely compiler generated special functions may behave incorrectly. Delete explicitly copy constructor and copy assignment operator to avoid potential errors.


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

1 Files Affected:

  • (modified) clang/lib/Sema/HLSLExternalSemaSource.cpp (+3)
diff --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp b/clang/lib/Sema/HLSLExternalSemaSource.cpp
index 79fc2751b73812..f21069d7d64ee4 100644
--- a/clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -546,6 +546,9 @@ struct BuiltinTypeMethodBuilder {
 public:
   ~BuiltinTypeMethodBuilder() { finalizeMethod(); }
 
+  BuiltinTypeMethodBuilder(BuiltinTypeMethodBuilder &Other) = delete;
+  BuiltinTypeMethodBuilder &operator=(BuiltinTypeMethodBuilder &Other) = delete;
+
   Expr *getResourceHandleExpr() {
     // The first statement added to a method or access to 'this' creates the
     // declaration.

Comment on lines 549 to 550
BuiltinTypeMethodBuilder(BuiltinTypeMethodBuilder &Other) = delete;
BuiltinTypeMethodBuilder &operator=(BuiltinTypeMethodBuilder &Other) = delete;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
BuiltinTypeMethodBuilder(BuiltinTypeMethodBuilder &Other) = delete;
BuiltinTypeMethodBuilder &operator=(BuiltinTypeMethodBuilder &Other) = delete;
BuiltinTypeMethodBuilder(const BuiltinTypeMethodBuilder &Other) = delete;
BuiltinTypeMethodBuilder &operator=(const BuiltinTypeMethodBuilder &Other) = delete;

Copy link
Contributor

@cor3ntin cor3ntin left a comment

Choose a reason for hiding this comment

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

LGTM modulo nit

@Fznamznon Fznamznon merged commit fbbf1be into llvm:main Dec 17, 2024
8 checks passed
@hekota
Copy link
Member

hekota commented Dec 17, 2024

Thank you @Fznamznon !

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 HLSL HLSL Language Support
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants