[NFC] Complete proper copying and resource cleanup in classes. (#118655)

Provide, where missing, a copy constructor, a copy assignment operator
or a destructor to prevent potential issues that can arise.
This commit is contained in:
Zahira Ammarguellat 2024-12-05 07:16:51 -08:00 committed by GitHub
parent 2bd3174226
commit f59b600c21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 24 additions and 1 deletions

View File

@ -81,6 +81,9 @@ public:
~ClangTidyContext();
ClangTidyContext(const ClangTidyContext &) = delete;
ClangTidyContext &operator=(const ClangTidyContext &) = delete;
/// Report any errors detected using this method.
///
/// This is still under heavy development and will likely change towards using

View File

@ -31,6 +31,8 @@ class NoLintDirectiveHandler {
public:
NoLintDirectiveHandler();
~NoLintDirectiveHandler();
NoLintDirectiveHandler(const NoLintDirectiveHandler &) = delete;
NoLintDirectiveHandler &operator=(const NoLintDirectiveHandler &) = delete;
bool shouldSuppress(DiagnosticsEngine::Level DiagLevel,
const Diagnostic &Diag, llvm::StringRef DiagName,

View File

@ -73,6 +73,9 @@ public:
/// The destructor blocks on any outstanding background tasks.
~ClangdLSPServer();
ClangdLSPServer(const ClangdLSPServer &other) = delete;
ClangdLSPServer &operator=(const ClangdLSPServer &other) = delete;
/// Run LSP server loop, communicating with the Transport provided in the
/// constructor. This method must not be executed more than once.
///

View File

@ -59,6 +59,9 @@ public:
~ParsedAST();
ParsedAST(const ParsedAST &Other) = delete;
ParsedAST &operator=(const ParsedAST &Other) = delete;
/// Note that the returned ast will not contain decls from the preamble that
/// were not deserialized during parsing. Clients should expect only decls
/// from the main file to be in the AST.

View File

@ -411,6 +411,9 @@ public:
if (Throttler)
Throttler->release(ID);
}
PreambleThrottlerRequest(const PreambleThrottlerRequest &) = delete;
PreambleThrottlerRequest &
operator=(const PreambleThrottlerRequest &) = delete;
private:
PreambleThrottler::RequestID ID;
@ -621,7 +624,8 @@ public:
AsyncTaskRunner *Tasks, Semaphore &Barrier,
const TUScheduler::Options &Opts, ParsingCallbacks &Callbacks);
~ASTWorker();
ASTWorker(const ASTWorker &other) = delete;
ASTWorker &operator=(const ASTWorker &other) = delete;
void update(ParseInputs Inputs, WantDiagnostics, bool ContentChanged);
void
runWithAST(llvm::StringRef Name,

View File

@ -242,6 +242,9 @@ public:
std::unique_ptr<ParsingCallbacks> ASTCallbacks = nullptr);
~TUScheduler();
TUScheduler(const TUScheduler &other) = delete;
TUScheduler &operator=(const TUScheduler &other) = delete;
struct FileStats {
std::size_t UsedBytesAST = 0;
std::size_t UsedBytesPreamble = 0;

View File

@ -328,6 +328,9 @@ public:
Preprocessor(const TokenStream &In, TokenStream &Out) : In(In), Out(Out) {}
~Preprocessor() { Out.finalize(); }
Preprocessor(const Preprocessor &other) = delete;
Preprocessor &operator=(const Preprocessor &other) = delete;
void walk(const DirectiveTree &T) {
for (const auto &C : T.Chunks)
std::visit(*this, C);

View File

@ -46,6 +46,8 @@ class Module {
public:
Module(llvm::StringRef Name, bool Problem);
~Module();
Module(const Module &other) = delete;
Module &operator=(const Module &other) = delete;
bool output(llvm::raw_fd_ostream &OS, int Indent);
Module *findSubModule(llvm::StringRef SubName);