[Lldb-commits] [lldb] 0512b01 - [lldb][NFC] Move trivial ValueObject getters/setters to the header
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Wed Feb 24 05:04:23 PST 2021
Author: Raphael Isemann
Date: 2021-02-24T14:04:01+01:00
New Revision: 0512b01ebede34fe5f6244d5ec8dde552fa4b375
URL: https://github.com/llvm/llvm-project/commit/0512b01ebede34fe5f6244d5ec8dde552fa4b375
DIFF: https://github.com/llvm/llvm-project/commit/0512b01ebede34fe5f6244d5ec8dde552fa4b375.diff
LOG: [lldb][NFC] Move trivial ValueObject getters/setters to the header
NFC refactoring that moves the definitions of all the trivial getters/setters to the header file
which is what we usually do in LLVM.
Reviewed By: #lldb, JDevlieghere
Differential Revision: https://reviews.llvm.org/D97298
Added:
Modified:
lldb/include/lldb/Core/ValueObject.h
lldb/source/Core/ValueObject.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h
index 70eecd106369..ab3a908eac49 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -349,10 +349,10 @@ class ValueObject {
void SetNeedsUpdate();
- CompilerType GetCompilerType();
+ CompilerType GetCompilerType() { return MaybeCalculateCompleteType(); }
// this vends a TypeImpl that is useful at the SB API layer
- virtual TypeImpl GetTypeImpl();
+ virtual TypeImpl GetTypeImpl() { return TypeImpl(GetCompilerType()); }
virtual bool CanProvideValue();
@@ -362,24 +362,32 @@ class ValueObject {
virtual lldb::ValueType GetValueType() const = 0;
// Subclasses can implement the functions below.
- virtual ConstString GetTypeName();
+ virtual ConstString GetTypeName() { return GetCompilerType().GetTypeName(); }
- virtual ConstString GetDisplayTypeName();
+ virtual ConstString GetDisplayTypeName() { return GetTypeName(); }
- virtual ConstString GetQualifiedTypeName();
+ virtual ConstString GetQualifiedTypeName() {
+ return GetCompilerType().GetTypeName();
+ }
- virtual lldb::LanguageType GetObjectRuntimeLanguage();
+ virtual lldb::LanguageType GetObjectRuntimeLanguage() {
+ return GetCompilerType().GetMinimumLanguage();
+ }
virtual uint32_t
- GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr);
+ GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr) {
+ return GetCompilerType().GetTypeInfo(pointee_or_element_compiler_type);
+ }
- virtual bool IsPointerType();
+ virtual bool IsPointerType() { return GetCompilerType().IsPointerType(); }
- virtual bool IsArrayType();
+ virtual bool IsArrayType() { return GetCompilerType().IsArrayType(); }
- virtual bool IsScalarType();
+ virtual bool IsScalarType() { return GetCompilerType().IsScalarType(); }
- virtual bool IsPointerOrReferenceType();
+ virtual bool IsPointerOrReferenceType() {
+ return GetCompilerType().IsPointerOrReferenceType();
+ }
virtual bool IsPossibleDynamicType();
@@ -393,7 +401,9 @@ class ValueObject {
virtual bool IsDereferenceOfParent() { return false; }
- bool IsIntegerType(bool &is_signed);
+ bool IsIntegerType(bool &is_signed) {
+ return GetCompilerType().IsIntegerType(is_signed);
+ }
virtual void GetExpressionPath(
Stream &s,
@@ -454,7 +464,7 @@ class ValueObject {
// The functions below should NOT be modified by subclasses
const Status &GetError();
- ConstString GetName() const;
+ ConstString GetName() const { return m_name; }
/// Returns a unique id for this ValueObject.
lldb::user_id_t GetID() const { return m_id.GetID(); }
@@ -484,9 +494,9 @@ class ValueObject {
size_t GetNumChildren(uint32_t max = UINT32_MAX);
- const Value &GetValue() const;
+ const Value &GetValue() const { return m_value; }
- Value &GetValue();
+ Value &GetValue() { return m_value; }
virtual bool ResolveValue(Scalar &scalar);
@@ -495,7 +505,9 @@ class ValueObject {
// potentially a few others
virtual bool IsLogicalTrue(Status &error);
- virtual const char *GetLocationAsCString();
+ virtual const char *GetLocationAsCString() {
+ return GetLocationAsCStringImpl(m_value, m_data);
+ }
const char *
GetSummaryAsCString(lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
@@ -530,11 +542,11 @@ class ValueObject {
PrintableRepresentationSpecialCases special =
PrintableRepresentationSpecialCases::eAllow,
bool do_dump_error = true);
- bool GetValueIsValid() const;
+ bool GetValueIsValid() const { return m_flags.m_value_is_valid; }
// If you call this on a newly created ValueObject, it will always return
// false.
- bool GetValueDidChange();
+ bool GetValueDidChange() { return m_flags.m_value_did_change; }
bool UpdateValueIfNeeded(bool update_format = true);
@@ -545,7 +557,7 @@ class ValueObject {
/// Change the name of the current ValueObject. Should *not* be used from a
/// synthetic child provider as it would change the name of the non synthetic
/// child as well.
- void SetName(ConstString name);
+ void SetName(ConstString name) { m_name = name; }
virtual lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
AddressType *address_type = nullptr);
@@ -575,9 +587,9 @@ class ValueObject {
lldb::DynamicValueType GetDynamicValueType();
- virtual lldb::ValueObjectSP GetStaticValue();
+ virtual lldb::ValueObjectSP GetStaticValue() { return GetSP(); }
- virtual lldb::ValueObjectSP GetNonSyntheticValue();
+ virtual lldb::ValueObjectSP GetNonSyntheticValue() { return GetSP(); }
lldb::ValueObjectSP GetSyntheticValue();
@@ -626,9 +638,13 @@ class ValueObject {
virtual bool DoesProvideSyntheticValue() { return false; }
- virtual bool IsSyntheticChildrenGenerated();
+ virtual bool IsSyntheticChildrenGenerated() {
+ return m_flags.m_is_synthetic_children_generated;
+ }
- virtual void SetSyntheticChildrenGenerated(bool b);
+ virtual void SetSyntheticChildrenGenerated(bool b) {
+ m_flags.m_is_synthetic_children_generated = b;
+ }
virtual SymbolContextScope *GetSymbolContextScope();
@@ -694,7 +710,9 @@ class ValueObject {
virtual lldb::LanguageType GetPreferredDisplayLanguage();
- void SetPreferredDisplayLanguage(lldb::LanguageType);
+ void SetPreferredDisplayLanguage(lldb::LanguageType lt) {
+ m_preferred_display_language = lt;
+ }
lldb::TypeSummaryImplSP GetSummaryFormat() {
UpdateFormatsIfNeeded();
@@ -768,9 +786,9 @@ class ValueObject {
virtual bool IsRuntimeSupportValue();
- virtual uint64_t GetLanguageFlags();
+ virtual uint64_t GetLanguageFlags() { return m_language_flags; }
- virtual void SetLanguageFlags(uint64_t flags);
+ virtual void SetLanguageFlags(uint64_t flags) { m_language_flags = flags; }
protected:
typedef ClusterManager<ValueObject> ValueObjectManager;
@@ -955,9 +973,11 @@ class ValueObject {
void SetNumChildren(size_t num_children);
- void SetValueDidChange(bool value_changed);
+ void SetValueDidChange(bool value_changed) {
+ m_flags.m_value_did_change = value_changed;
+ }
- void SetValueIsValid(bool valid);
+ void SetValueIsValid(bool valid) { m_flags.m_value_is_valid = valid; }
void ClearUserVisibleData(
uint32_t items = ValueObject::eClearUserVisibleDataItemsAllStrings);
@@ -975,7 +995,7 @@ class ValueObject {
const char *GetLocationAsCStringImpl(const Value &value,
const DataExtractor &data);
- bool IsChecksumEmpty();
+ bool IsChecksumEmpty() { return m_value_checksum.empty(); }
void SetPreferredDisplayLanguageIfNeeded(lldb::LanguageType);
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 58f794f3b8d1..1988155a16ac 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -62,6 +62,8 @@
#include <stdio.h>
#include <string.h>
+#include <lldb/Core/ValueObject.h>
+
namespace lldb_private {
class ExecutionContextScope;
}
@@ -271,11 +273,7 @@ CompilerType ValueObject::MaybeCalculateCompleteType() {
return compiler_type;
}
-CompilerType ValueObject::GetCompilerType() {
- return MaybeCalculateCompleteType();
-}
-TypeImpl ValueObject::GetTypeImpl() { return TypeImpl(GetCompilerType()); }
DataExtractor &ValueObject::GetDataExtractor() {
UpdateValueIfNeeded(false);
@@ -287,12 +285,6 @@ const Status &ValueObject::GetError() {
return m_error;
}
-ConstString ValueObject::GetName() const { return m_name; }
-
-const char *ValueObject::GetLocationAsCString() {
- return GetLocationAsCStringImpl(m_value, m_data);
-}
-
const char *ValueObject::GetLocationAsCStringImpl(const Value &value,
const DataExtractor &data) {
if (UpdateValueIfNeeded(false)) {
@@ -337,10 +329,6 @@ const char *ValueObject::GetLocationAsCStringImpl(const Value &value,
return m_location_str.c_str();
}
-Value &ValueObject::GetValue() { return m_value; }
-
-const Value &ValueObject::GetValue() const { return m_value; }
-
bool ValueObject::ResolveValue(Scalar &scalar) {
if (UpdateValueIfNeeded(
false)) // make sure that you are up to date before returning anything
@@ -384,16 +372,6 @@ bool ValueObject::IsLogicalTrue(Status &error) {
return ret;
}
-bool ValueObject::GetValueIsValid() const { return m_flags.m_value_is_valid; }
-
-void ValueObject::SetValueIsValid(bool b) { m_flags.m_value_is_valid = b; }
-
-bool ValueObject::GetValueDidChange() { return m_flags.m_value_did_change; }
-
-void ValueObject::SetValueDidChange(bool value_changed) {
- m_flags.m_value_did_change = value_changed;
-}
-
ValueObjectSP ValueObject::GetChildAtIndex(size_t idx, bool can_create) {
ValueObjectSP child_sp;
// We may need to update our value if we are dynamic
@@ -550,8 +528,6 @@ void ValueObject::SetNumChildren(size_t num_children) {
m_children.SetChildrenCount(num_children);
}
-void ValueObject::SetName(ConstString name) { m_name = name; }
-
ValueObject *ValueObject::CreateChildAtIndex(size_t idx,
bool synthetic_array_member,
int32_t synthetic_index) {
@@ -1573,20 +1549,6 @@ bool ValueObject::GetDeclaration(Declaration &decl) {
return false;
}
-ConstString ValueObject::GetTypeName() {
- return GetCompilerType().GetTypeName();
-}
-
-ConstString ValueObject::GetDisplayTypeName() { return GetTypeName(); }
-
-ConstString ValueObject::GetQualifiedTypeName() {
- return GetCompilerType().GetTypeName();
-}
-
-LanguageType ValueObject::GetObjectRuntimeLanguage() {
- return GetCompilerType().GetMinimumLanguage();
-}
-
void ValueObject::AddSyntheticChild(ConstString key,
ValueObject *valobj) {
m_synthetic_children[key] = valobj;
@@ -1601,25 +1563,6 @@ ValueObjectSP ValueObject::GetSyntheticChild(ConstString key) const {
return synthetic_child_sp;
}
-uint32_t
-ValueObject::GetTypeInfo(CompilerType *pointee_or_element_compiler_type) {
- return GetCompilerType().GetTypeInfo(pointee_or_element_compiler_type);
-}
-
-bool ValueObject::IsPointerType() { return GetCompilerType().IsPointerType(); }
-
-bool ValueObject::IsArrayType() { return GetCompilerType().IsArrayType(); }
-
-bool ValueObject::IsScalarType() { return GetCompilerType().IsScalarType(); }
-
-bool ValueObject::IsIntegerType(bool &is_signed) {
- return GetCompilerType().IsIntegerType(is_signed);
-}
-
-bool ValueObject::IsPointerOrReferenceType() {
- return GetCompilerType().IsPointerOrReferenceType();
-}
-
bool ValueObject::IsPossibleDynamicType() {
ExecutionContext exe_ctx(GetExecutionContextRef());
Process *process = exe_ctx.GetProcessPtr();
@@ -1899,10 +1842,6 @@ ValueObjectSP ValueObject::GetDynamicValue(DynamicValueType use_dynamic) {
return ValueObjectSP();
}
-ValueObjectSP ValueObject::GetStaticValue() { return GetSP(); }
-
-lldb::ValueObjectSP ValueObject::GetNonSyntheticValue() { return GetSP(); }
-
ValueObjectSP ValueObject::GetSyntheticValue() {
CalculateSyntheticValue();
@@ -3154,10 +3093,6 @@ lldb::LanguageType ValueObject::GetPreferredDisplayLanguage() {
return (m_preferred_display_language = type); // only compute it once
}
-void ValueObject::SetPreferredDisplayLanguage(lldb::LanguageType lt) {
- m_preferred_display_language = lt;
-}
-
void ValueObject::SetPreferredDisplayLanguageIfNeeded(lldb::LanguageType lt) {
if (m_preferred_display_language == lldb::eLanguageTypeUnknown)
SetPreferredDisplayLanguage(lt);
@@ -3171,7 +3106,7 @@ bool ValueObject::CanProvideValue() {
return (!type.IsValid()) || (0 != (type.GetTypeInfo() & eTypeHasValue));
}
-bool ValueObject::IsChecksumEmpty() { return m_value_checksum.empty(); }
+
ValueObjectSP ValueObject::Persist() {
if (!UpdateValueIfNeeded())
@@ -3200,15 +3135,3 @@ ValueObjectSP ValueObject::Persist() {
return persistent_var_sp->GetValueObject();
}
-
-bool ValueObject::IsSyntheticChildrenGenerated() {
- return m_flags.m_is_synthetic_children_generated;
-}
-
-void ValueObject::SetSyntheticChildrenGenerated(bool b) {
- m_flags.m_is_synthetic_children_generated = b;
-}
-
-uint64_t ValueObject::GetLanguageFlags() { return m_language_flags; }
-
-void ValueObject::SetLanguageFlags(uint64_t flags) { m_language_flags = flags; }
More information about the lldb-commits
mailing list