[clang] [Clang] Prevent Copying of LateParsedClass Instances (PR #109428)

via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 20 07:11:52 PDT 2024


https://github.com/smanna12 created https://github.com/llvm/llvm-project/pull/109428

Class clang::Parser::LateParsedClass owns resources that are freed in its destructor but has no user-written assignment operator.
This commit explicitly deletes the copy constructor and copy assignment operator for the LateParsedClass. 


>From d792de91f9a01b927a274c83f0d2553ac06aa3cb Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" <soumi.manna at intel.com>
Date: Fri, 20 Sep 2024 07:07:46 -0700
Subject: [PATCH] [Clang] Prevent Copying of LateParsedClass Instances

---
 clang/include/clang/Parse/Parser.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h
index 47f72135c97cff..79b08032bd1621 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -1355,6 +1355,10 @@ class Parser : public CodeCompletionHandler {
     void ParseLexedAttributes() override;
     void ParseLexedPragmas() override;
 
+    // Delete copy constructor and copy assignment operator.
+    LateParsedClass(const LateParsedClass&) = delete;
+    LateParsedClass& operator=(const LateParsedClass&) = delete;
+
   private:
     Parser *Self;
     ParsingClass *Class;



More information about the cfe-commits mailing list