[Lldb-commits] [lldb] 0871f22 - [lldb][NFCI] Use size_t in OptionValueProperties

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Mon Jun 5 12:57:57 PDT 2023


Author: Alex Langford
Date: 2023-06-05T12:57:43-07:00
New Revision: 0871f22edca5036dad2aba0c4461a3975651b0c3

URL: https://github.com/llvm/llvm-project/commit/0871f22edca5036dad2aba0c4461a3975651b0c3
DIFF: https://github.com/llvm/llvm-project/commit/0871f22edca5036dad2aba0c4461a3975651b0c3.diff

LOG: [lldb][NFCI] Use size_t in OptionValueProperties

In many places we're using uint32_t where we should be using size_t.
We should be consistent.

Differential Revision: https://reviews.llvm.org/D151949

Added: 
    

Modified: 
    lldb/include/lldb/Interpreter/OptionValueProperties.h
    lldb/source/Interpreter/OptionValueProperties.cpp
    lldb/source/Target/Process.cpp
    lldb/source/Target/Target.cpp
    lldb/source/Target/Thread.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h b/lldb/include/lldb/Interpreter/OptionValueProperties.h
index e20ba2c3af71b..3f40290f1e21d 100644
--- a/lldb/include/lldb/Interpreter/OptionValueProperties.h
+++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h
@@ -68,7 +68,7 @@ class OptionValueProperties
   // Get the index of a property given its exact name in this property
   // collection, "name" can't be a path to a property path that refers to a
   // property within a property
-  virtual uint32_t GetPropertyIndex(ConstString name) const;
+  virtual size_t GetPropertyIndex(ConstString name) const;
 
   // Get a property by exact name exists in this property collection, name can
   // not be a path to a property path that refers to a property within a
@@ -78,7 +78,7 @@ class OptionValueProperties
               const ExecutionContext *exe_ctx = nullptr) const;
 
   virtual const Property *
-  GetPropertyAtIndex(uint32_t idx,
+  GetPropertyAtIndex(size_t idx,
                      const ExecutionContext *exe_ctx = nullptr) const {
     return ProtectedGetPropertyAtIndex(idx);
   }
@@ -91,7 +91,7 @@ class OptionValueProperties
                     llvm::StringRef property_path) const;
 
   virtual lldb::OptionValueSP
-  GetPropertyValueAtIndex(uint32_t idx, const ExecutionContext *exe_ctx) const;
+  GetPropertyValueAtIndex(size_t idx, const ExecutionContext *exe_ctx) const;
 
   virtual lldb::OptionValueSP GetValueForKey(const ExecutionContext *exe_ctx,
                                              ConstString key) const;
@@ -104,32 +104,32 @@ class OptionValueProperties
                      llvm::StringRef path, llvm::StringRef value) override;
 
   bool
-  GetPropertyAtIndexAsArgs(uint32_t idx, Args &args,
+  GetPropertyAtIndexAsArgs(size_t idx, Args &args,
                            const ExecutionContext *exe_ctx = nullptr) const;
 
-  bool SetPropertyAtIndexFromArgs(uint32_t idx, const Args &args,
+  bool SetPropertyAtIndexFromArgs(size_t idx, const Args &args,
                                   const ExecutionContext *exe_ctx = nullptr);
 
   OptionValueDictionary *GetPropertyAtIndexAsOptionValueDictionary(
-      uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const;
+      size_t idx, const ExecutionContext *exe_ctx = nullptr) const;
 
   OptionValueSInt64 *GetPropertyAtIndexAsOptionValueSInt64(
-      uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const;
+      size_t idx, const ExecutionContext *exe_ctx = nullptr) const;
 
   OptionValueUInt64 *GetPropertyAtIndexAsOptionValueUInt64(
-      uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const;
+      size_t idx, const ExecutionContext *exe_ctx = nullptr) const;
 
   OptionValueString *GetPropertyAtIndexAsOptionValueString(
-      uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const;
+      size_t idx, const ExecutionContext *exe_ctx = nullptr) const;
 
   OptionValueFileSpec *GetPropertyAtIndexAsOptionValueFileSpec(
-      uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const;
+      size_t idx, const ExecutionContext *exe_ctx = nullptr) const;
 
   OptionValuePathMappings *GetPropertyAtIndexAsOptionValuePathMappings(
-      uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const;
+      size_t idx, const ExecutionContext *exe_ctx = nullptr) const;
 
   OptionValueFileSpecList *GetPropertyAtIndexAsOptionValueFileSpecList(
-      uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const;
+      size_t idx, const ExecutionContext *exe_ctx = nullptr) const;
 
   void AppendProperty(ConstString name, llvm::StringRef desc, bool is_global,
                       const lldb::OptionValueSP &value_sp);
@@ -137,11 +137,11 @@ class OptionValueProperties
   lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx,
                                                ConstString name);
 
-  void SetValueChangedCallback(uint32_t property_idx,
+  void SetValueChangedCallback(size_t property_idx,
                                std::function<void()> callback);
 
   template <typename T>
-  auto GetPropertyAtIndexAs(uint32_t idx,
+  auto GetPropertyAtIndexAs(size_t idx,
                             const ExecutionContext *exe_ctx = nullptr) const {
     if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) {
       if (OptionValue *value = property->GetValue().get())
@@ -154,7 +154,7 @@ class OptionValueProperties
   }
 
   template <typename T>
-  bool SetPropertyAtIndex(uint32_t idx, T t,
+  bool SetPropertyAtIndex(size_t idx, T t,
                           const ExecutionContext *exe_ctx = nullptr) const {
     if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) {
       if (OptionValue *value = property->GetValue().get()) {
@@ -166,12 +166,12 @@ class OptionValueProperties
   }
 
 protected:
-  Property *ProtectedGetPropertyAtIndex(uint32_t idx) {
+  Property *ProtectedGetPropertyAtIndex(size_t idx) {
     assert(idx < m_properties.size() && "invalid property index");
     return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
   }
 
-  const Property *ProtectedGetPropertyAtIndex(uint32_t idx) const {
+  const Property *ProtectedGetPropertyAtIndex(size_t idx) const {
     assert(idx < m_properties.size() && "invalid property index");
     return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
   }

diff  --git a/lldb/source/Interpreter/OptionValueProperties.cpp b/lldb/source/Interpreter/OptionValueProperties.cpp
index 36d732d2d25e1..c2b5ceb344a73 100644
--- a/lldb/source/Interpreter/OptionValueProperties.cpp
+++ b/lldb/source/Interpreter/OptionValueProperties.cpp
@@ -35,7 +35,7 @@ void OptionValueProperties::Initialize(const PropertyDefinitions &defs) {
 }
 
 void OptionValueProperties::SetValueChangedCallback(
-    uint32_t property_idx, std::function<void()> callback) {
+    size_t property_idx, std::function<void()> callback) {
   Property *property = ProtectedGetPropertyAtIndex(property_idx);
   if (property)
     property->SetValueChangedCallback(std::move(callback));
@@ -138,7 +138,7 @@ Status OptionValueProperties::SetSubValue(const ExecutionContext *exe_ctx,
   return error;
 }
 
-uint32_t OptionValueProperties::GetPropertyIndex(ConstString name) const {
+size_t OptionValueProperties::GetPropertyIndex(ConstString name) const {
   return m_name_to_index.Find(name, SIZE_MAX);
 }
 
@@ -149,7 +149,7 @@ OptionValueProperties::GetProperty(ConstString name,
 }
 
 lldb::OptionValueSP OptionValueProperties::GetPropertyValueAtIndex(
-    uint32_t idx, const ExecutionContext *exe_ctx) const {
+    size_t idx, const ExecutionContext *exe_ctx) const {
   const Property *setting = GetPropertyAtIndex(idx, exe_ctx);
   if (setting)
     return setting->GetValue();
@@ -158,7 +158,7 @@ lldb::OptionValueSP OptionValueProperties::GetPropertyValueAtIndex(
 
 OptionValuePathMappings *
 OptionValueProperties::GetPropertyAtIndexAsOptionValuePathMappings(
-    uint32_t idx, const ExecutionContext *exe_ctx) const {
+    size_t idx, const ExecutionContext *exe_ctx) const {
   OptionValueSP value_sp(GetPropertyValueAtIndex(idx, exe_ctx));
   if (value_sp)
     return value_sp->GetAsPathMappings();
@@ -167,7 +167,7 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValuePathMappings(
 
 OptionValueFileSpecList *
 OptionValueProperties::GetPropertyAtIndexAsOptionValueFileSpecList(
-    uint32_t idx, const ExecutionContext *exe_ctx) const {
+    size_t idx, const ExecutionContext *exe_ctx) const {
   OptionValueSP value_sp(GetPropertyValueAtIndex(idx, exe_ctx));
   if (value_sp)
     return value_sp->GetAsFileSpecList();
@@ -175,7 +175,7 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValueFileSpecList(
 }
 
 bool OptionValueProperties::GetPropertyAtIndexAsArgs(
-    uint32_t idx, Args &args, const ExecutionContext *exe_ctx) const {
+    size_t idx, Args &args, const ExecutionContext *exe_ctx) const {
   const Property *property = GetPropertyAtIndex(idx, exe_ctx);
   if (!property)
     return false;
@@ -206,7 +206,7 @@ bool OptionValueProperties::GetPropertyAtIndexAsArgs(
 }
 
 bool OptionValueProperties::SetPropertyAtIndexFromArgs(
-    uint32_t idx, const Args &args, const ExecutionContext *exe_ctx) {
+    size_t idx, const Args &args, const ExecutionContext *exe_ctx) {
   const Property *property = GetPropertyAtIndex(idx, exe_ctx);
   if (!property)
     return false;
@@ -232,7 +232,7 @@ bool OptionValueProperties::SetPropertyAtIndexFromArgs(
 
 OptionValueDictionary *
 OptionValueProperties::GetPropertyAtIndexAsOptionValueDictionary(
-    uint32_t idx, const ExecutionContext *exe_ctx) const {
+    size_t idx, const ExecutionContext *exe_ctx) const {
   const Property *property = GetPropertyAtIndex(idx, exe_ctx);
   if (property)
     return property->GetValue()->GetAsDictionary();
@@ -241,7 +241,7 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValueDictionary(
 
 OptionValueFileSpec *
 OptionValueProperties::GetPropertyAtIndexAsOptionValueFileSpec(
-    uint32_t idx, const ExecutionContext *exe_ctx) const {
+    size_t idx, const ExecutionContext *exe_ctx) const {
   const Property *property = GetPropertyAtIndex(idx, exe_ctx);
   if (property) {
     OptionValue *value = property->GetValue().get();
@@ -252,7 +252,7 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValueFileSpec(
 }
 
 OptionValueSInt64 *OptionValueProperties::GetPropertyAtIndexAsOptionValueSInt64(
-    uint32_t idx, const ExecutionContext *exe_ctx) const {
+    size_t idx, const ExecutionContext *exe_ctx) const {
   const Property *property = GetPropertyAtIndex(idx, exe_ctx);
   if (property) {
     OptionValue *value = property->GetValue().get();
@@ -263,7 +263,7 @@ OptionValueSInt64 *OptionValueProperties::GetPropertyAtIndexAsOptionValueSInt64(
 }
 
 OptionValueUInt64 *OptionValueProperties::GetPropertyAtIndexAsOptionValueUInt64(
-    uint32_t idx, const ExecutionContext *exe_ctx) const {
+    size_t idx, const ExecutionContext *exe_ctx) const {
   const Property *property = GetPropertyAtIndex(idx, exe_ctx);
   if (property) {
     OptionValue *value = property->GetValue().get();
@@ -274,7 +274,7 @@ OptionValueUInt64 *OptionValueProperties::GetPropertyAtIndexAsOptionValueUInt64(
 }
 
 OptionValueString *OptionValueProperties::GetPropertyAtIndexAsOptionValueString(
-    uint32_t idx, const ExecutionContext *exe_ctx) const {
+    size_t idx, const ExecutionContext *exe_ctx) const {
   OptionValueSP value_sp(GetPropertyValueAtIndex(idx, exe_ctx));
   if (value_sp)
     return value_sp->GetAsString();

diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index c5ec8a36fc7c1..572b73871760c 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -93,7 +93,7 @@ class ProcessOptionValueProperties
   ProcessOptionValueProperties(ConstString name) : Cloneable(name) {}
 
   const Property *
-  GetPropertyAtIndex(uint32_t idx,
+  GetPropertyAtIndex(size_t idx,
                      const ExecutionContext *exe_ctx) const override {
     // When getting the value for a key from the process options, we will
     // always try and grab the setting from the current process if there is

diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index b5a6e4ad22e4d..0cc66ee0dc4c1 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -4008,7 +4008,7 @@ class TargetOptionValueProperties
   TargetOptionValueProperties(ConstString name) : Cloneable(name) {}
 
   const Property *
-  GetPropertyAtIndex(uint32_t idx,
+  GetPropertyAtIndex(size_t idx,
                      const ExecutionContext *exe_ctx = nullptr) const override {
     // When getting the value for a key from the target options, we will always
     // try and grab the setting from the current target if there is one. Else

diff  --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index 2eeb037381094..ec4ffcbd92050 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -79,7 +79,7 @@ class ThreadOptionValueProperties
   ThreadOptionValueProperties(ConstString name) : Cloneable(name) {}
 
   const Property *
-  GetPropertyAtIndex(uint32_t idx,
+  GetPropertyAtIndex(size_t idx,
                      const ExecutionContext *exe_ctx) const override {
     // When getting the value for a key from the thread options, we will always
     // try and grab the setting from the current thread if there is one. Else


        


More information about the lldb-commits mailing list