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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: None (smanna12)

<details>
<summary>Changes</summary>

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. 


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


1 Files Affected:

- (modified) clang/include/clang/Parse/Parser.h (+4) 


``````````diff
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;

``````````

</details>


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


More information about the cfe-commits mailing list