[clang] [HLSL][NFC] Fix static analyzer concerns (PR #120090)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 17 04:12:04 PST 2024


https://github.com/Fznamznon updated https://github.com/llvm/llvm-project/pull/120090

>From e85b64f919dc3b9e9590f9f344fcb9c277761789 Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" <mariya.podchishchaeva at intel.com>
Date: Mon, 16 Dec 2024 06:29:17 -0800
Subject: [PATCH 1/2] [HLSL][NFC] Fix static analyzer concerns

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.
---
 clang/lib/Sema/HLSLExternalSemaSource.cpp | 3 +++
 1 file changed, 3 insertions(+)

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.

>From 0ee26bd14f73b552fa3c769d2de1ac39f421ede0 Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" <mariya.podchishchaeva at intel.com>
Date: Tue, 17 Dec 2024 03:34:42 -0800
Subject: [PATCH 2/2] Fix a nit

---
 clang/lib/Sema/HLSLExternalSemaSource.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

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



More information about the cfe-commits mailing list