Skip to content
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

[Clang] Prevent Copying of LateParsedClass Instances #109428

Merged
merged 2 commits into from
Sep 20, 2024
Merged

Conversation

smanna12
Copy link
Contributor

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.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Sep 20, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 20, 2024

@llvm/pr-subscribers-clang

Author: None (smanna12)

Changes

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

Copy link

github-actions bot commented Sep 20, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Contributor

@tahonermann tahonermann left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks @smanna12!

@smanna12
Copy link
Contributor Author

Thank you @tahonermann for reviews!

@smanna12 smanna12 merged commit efb5831 into llvm:main Sep 20, 2024
8 checks passed
@smanna12 smanna12 deleted the FixCopy branch September 20, 2024 17:09
xgupta pushed a commit to xgupta/llvm-project that referenced this pull request Oct 4, 2024
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.
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