Skip to content

[lldb][nfc] Fix missing move operations and constness of methods #142052

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

Merged
merged 1 commit into from
May 30, 2025

Conversation

felipepiovezan
Copy link
Contributor

This PR adds the missing move operators for VariableList: this class are just a wrapper around a vector, so it can use the default move operations. Subsequent patches will want to return VariableLists from functions, so the move operation is required (the copy constructors are deleted).

It also fixes constness for a method in DiagnosticManager returning its list of diagnostics. Previously, the method always returned a const list, even though the method was not const itself. Subsequent patches will make use of the ability to mutate the diagnostics.

(cherry picked from commit eef2c3e214b737c530bd66a77350c1cfe3b6921e)

This PR adds the missing move operators for VariableList: this class are
just a wrapper around a vector, so it can use the default move
operations. Subsequent patches will want to return VariableLists from
functions, so the move operation is required (the copy constructors are
deleted).

It also fixes constness for a method in DiagnosticManager returning its
list of diagnostics. Previously, the method always returned a const
list, even though the method was not const itself. Subsequent patches
will make use of the ability to mutate the diagnostics.

(cherry picked from commit eef2c3e214b737c530bd66a77350c1cfe3b6921e)
@llvmbot
Copy link
Member

llvmbot commented May 29, 2025

@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)

Changes

This PR adds the missing move operators for VariableList: this class are just a wrapper around a vector, so it can use the default move operations. Subsequent patches will want to return VariableLists from functions, so the move operation is required (the copy constructors are deleted).

It also fixes constness for a method in DiagnosticManager returning its list of diagnostics. Previously, the method always returned a const list, even though the method was not const itself. Subsequent patches will make use of the ability to mutate the diagnostics.

(cherry picked from commit eef2c3e214b737c530bd66a77350c1cfe3b6921e)


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

2 Files Affected:

  • (modified) lldb/include/lldb/Expression/DiagnosticManager.h (+2-1)
  • (modified) lldb/include/lldb/Symbol/VariableList.h (+3)
diff --git a/lldb/include/lldb/Expression/DiagnosticManager.h b/lldb/include/lldb/Expression/DiagnosticManager.h
index cc802b6f48334..fc49349d1b7c3 100644
--- a/lldb/include/lldb/Expression/DiagnosticManager.h
+++ b/lldb/include/lldb/Expression/DiagnosticManager.h
@@ -107,7 +107,8 @@ class DiagnosticManager {
     m_fixed_expression.clear();
   }
 
-  const DiagnosticList &Diagnostics() { return m_diagnostics; }
+  const DiagnosticList &Diagnostics() const { return m_diagnostics; }
+  DiagnosticList &Diagnostics() { return m_diagnostics; }
 
   bool HasFixIts() const {
     return llvm::any_of(m_diagnostics,
diff --git a/lldb/include/lldb/Symbol/VariableList.h b/lldb/include/lldb/Symbol/VariableList.h
index fd15f3ae6891f..ead300a815cb9 100644
--- a/lldb/include/lldb/Symbol/VariableList.h
+++ b/lldb/include/lldb/Symbol/VariableList.h
@@ -24,6 +24,9 @@ class VariableList {
   VariableList();
   virtual ~VariableList();
 
+  VariableList(VariableList &&) = default;
+  VariableList &operator=(VariableList &&) = default;
+
   void AddVariable(const lldb::VariableSP &var_sp);
 
   bool AddVariableIfUnique(const lldb::VariableSP &var_sp);

@felipepiovezan felipepiovezan merged commit 03d1f3d into llvm:main May 30, 2025
12 checks passed
@felipepiovezan felipepiovezan deleted the felipe/nfc_ctors branch May 30, 2025 19:46
felipepiovezan added a commit to felipepiovezan/llvm-project that referenced this pull request May 30, 2025
…m#142052)

This PR adds the missing move operators for VariableList: this class is
just a wrapper around a vector, so it can use the default move
operations. Subsequent patches will want to return VariableLists from
functions, so the move operation is required (the copy constructors are
deleted).

It also fixes constness for a method in DiagnosticManager returning its
list of diagnostics. Previously, the method always returned a const
list, even though the method was not const itself. Subsequent patches
will make use of the ability to mutate the diagnostics.

(cherry picked from commit 03d1f3d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants