Skip to content

Commit f59b600

Browse files
authored
[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.
1 parent 2bd3174 commit f59b600

File tree

8 files changed

+24
-1
lines changed

8 files changed

+24
-1
lines changed

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ class ClangTidyContext {
8181

8282
~ClangTidyContext();
8383

84+
ClangTidyContext(const ClangTidyContext &) = delete;
85+
ClangTidyContext &operator=(const ClangTidyContext &) = delete;
86+
8487
/// Report any errors detected using this method.
8588
///
8689
/// This is still under heavy development and will likely change towards using

clang-tools-extra/clang-tidy/NoLintDirectiveHandler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class NoLintDirectiveHandler {
3131
public:
3232
NoLintDirectiveHandler();
3333
~NoLintDirectiveHandler();
34+
NoLintDirectiveHandler(const NoLintDirectiveHandler &) = delete;
35+
NoLintDirectiveHandler &operator=(const NoLintDirectiveHandler &) = delete;
3436

3537
bool shouldSuppress(DiagnosticsEngine::Level DiagLevel,
3638
const Diagnostic &Diag, llvm::StringRef DiagName,

clang-tools-extra/clangd/ClangdLSPServer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ class ClangdLSPServer : private ClangdServer::Callbacks,
7373
/// The destructor blocks on any outstanding background tasks.
7474
~ClangdLSPServer();
7575

76+
ClangdLSPServer(const ClangdLSPServer &other) = delete;
77+
ClangdLSPServer &operator=(const ClangdLSPServer &other) = delete;
78+
7679
/// Run LSP server loop, communicating with the Transport provided in the
7780
/// constructor. This method must not be executed more than once.
7881
///

clang-tools-extra/clangd/ParsedAST.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ class ParsedAST {
5959

6060
~ParsedAST();
6161

62+
ParsedAST(const ParsedAST &Other) = delete;
63+
ParsedAST &operator=(const ParsedAST &Other) = delete;
64+
6265
/// Note that the returned ast will not contain decls from the preamble that
6366
/// were not deserialized during parsing. Clients should expect only decls
6467
/// from the main file to be in the AST.

clang-tools-extra/clangd/TUScheduler.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,9 @@ class PreambleThrottlerRequest {
411411
if (Throttler)
412412
Throttler->release(ID);
413413
}
414+
PreambleThrottlerRequest(const PreambleThrottlerRequest &) = delete;
415+
PreambleThrottlerRequest &
416+
operator=(const PreambleThrottlerRequest &) = delete;
414417

415418
private:
416419
PreambleThrottler::RequestID ID;
@@ -621,7 +624,8 @@ class ASTWorker {
621624
AsyncTaskRunner *Tasks, Semaphore &Barrier,
622625
const TUScheduler::Options &Opts, ParsingCallbacks &Callbacks);
623626
~ASTWorker();
624-
627+
ASTWorker(const ASTWorker &other) = delete;
628+
ASTWorker &operator=(const ASTWorker &other) = delete;
625629
void update(ParseInputs Inputs, WantDiagnostics, bool ContentChanged);
626630
void
627631
runWithAST(llvm::StringRef Name,

clang-tools-extra/clangd/TUScheduler.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ class TUScheduler {
242242
std::unique_ptr<ParsingCallbacks> ASTCallbacks = nullptr);
243243
~TUScheduler();
244244

245+
TUScheduler(const TUScheduler &other) = delete;
246+
TUScheduler &operator=(const TUScheduler &other) = delete;
247+
245248
struct FileStats {
246249
std::size_t UsedBytesAST = 0;
247250
std::size_t UsedBytesPreamble = 0;

clang-tools-extra/clangd/support/DirectiveTree.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@ class Preprocessor {
328328
Preprocessor(const TokenStream &In, TokenStream &Out) : In(In), Out(Out) {}
329329
~Preprocessor() { Out.finalize(); }
330330

331+
Preprocessor(const Preprocessor &other) = delete;
332+
Preprocessor &operator=(const Preprocessor &other) = delete;
333+
331334
void walk(const DirectiveTree &T) {
332335
for (const auto &C : T.Chunks)
333336
std::visit(*this, C);

clang-tools-extra/modularize/ModuleAssistant.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class Module {
4646
public:
4747
Module(llvm::StringRef Name, bool Problem);
4848
~Module();
49+
Module(const Module &other) = delete;
50+
Module &operator=(const Module &other) = delete;
4951
bool output(llvm::raw_fd_ostream &OS, int Indent);
5052
Module *findSubModule(llvm::StringRef SubName);
5153

0 commit comments

Comments
 (0)