[Lldb-commits] [lldb] r166857 - in /lldb/trunk: include/lldb/Core/ValueObjectCast.h include/lldb/Core/ValueObjectDynamicValue.h lldb.xcodeproj/project.pbxproj source/Core/ValueObject.cpp source/Core/ValueObjectCast.cpp source/Core/ValueObjectDynamicValue.cpp

Enrico Granata egranata at apple.com
Fri Oct 26 19:05:48 PDT 2012


Author: enrico
Date: Fri Oct 26 21:05:48 2012
New Revision: 166857

URL: http://llvm.org/viewvc/llvm-project?rev=166857&view=rev
Log:
Moving ValueObjectCast over to its own .h/.cpp files instead of sharing ValueObjectDynamic.h/.cpp
Removing the IsDynamic() and GetStaticValue() calls, so that they will default to the base class behavior:
 - non-dynamic
 - itself as the static value
This is in contrast with the previous behavior which could be confusing and could potentially cause issues when using those objects


Added:
    lldb/trunk/include/lldb/Core/ValueObjectCast.h
    lldb/trunk/source/Core/ValueObjectCast.cpp
Modified:
    lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/Core/ValueObject.cpp
    lldb/trunk/source/Core/ValueObjectDynamicValue.cpp

Added: lldb/trunk/include/lldb/Core/ValueObjectCast.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectCast.h?rev=166857&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectCast.h (added)
+++ lldb/trunk/include/lldb/Core/ValueObjectCast.h Fri Oct 26 21:05:48 2012
@@ -0,0 +1,90 @@
+//===-- ValueObjectDynamicValue.h -----------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_ValueObjectCast_h_
+#define liblldb_ValueObjectCast_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/ValueObject.h"
+
+namespace lldb_private {
+
+//---------------------------------------------------------------------------------
+// A ValueObject that represents a given value represented as a different type.
+//---------------------------------------------------------------------------------
+class ValueObjectCast : public ValueObject
+{
+public:
+    static lldb::ValueObjectSP
+    Create (ValueObject &parent, 
+            const ConstString &name, 
+            const ClangASTType &cast_type);
+
+    virtual
+    ~ValueObjectCast();
+    
+    virtual size_t
+    GetByteSize();
+    
+    virtual uint32_t
+    CalculateNumChildren();
+    
+    virtual lldb::ValueType
+    GetValueType() const;
+    
+    virtual bool
+    IsInScope ();
+    
+    virtual ValueObject *
+    GetParent()
+    {
+        if (m_parent)
+            return m_parent->GetParent();
+        else
+            return NULL;
+    }
+    
+    virtual const ValueObject *
+    GetParent() const
+    {
+        if (m_parent)
+            return m_parent->GetParent();
+        else
+            return NULL;
+    }
+    
+protected:
+    virtual bool
+    UpdateValue ();
+    
+    virtual clang::ASTContext *
+    GetClangASTImpl ();
+    
+    virtual lldb::clang_type_t
+    GetClangTypeImpl ();
+    
+    ClangASTType m_cast_type;
+    
+private:
+    ValueObjectCast (ValueObject &parent, 
+                     const ConstString &name, 
+                     const ClangASTType &cast_type);
+    
+    //------------------------------------------------------------------
+    // For ValueObject only
+    //------------------------------------------------------------------
+    DISALLOW_COPY_AND_ASSIGN (ValueObjectCast);
+};
+
+} // namespace lldb_private
+
+#endif  // liblldb_ValueObjectCast_h_

Modified: lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h?rev=166857&r1=166856&r2=166857&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h Fri Oct 26 21:05:48 2012
@@ -15,86 +15,9 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Core/ValueObject.h"
-#include "lldb/Symbol/ClangASTType.h"
 
 namespace lldb_private {
 
-    class ValueObjectCast : public ValueObject
-    {
-    public:
-        static lldb::ValueObjectSP
-        Create (ValueObject &parent, 
-                const ConstString &name, 
-                const ClangASTType &cast_type);
-
-        virtual
-        ~ValueObjectCast();
-        
-        virtual size_t
-        GetByteSize();
-        
-        virtual uint32_t
-        CalculateNumChildren();
-        
-        virtual lldb::ValueType
-        GetValueType() const;
-        
-        virtual bool
-        IsInScope ();
-        
-        virtual bool
-        IsDynamic ()
-        {
-            return true;
-        }
-        
-        virtual ValueObject *
-        GetParent()
-        {
-            if (m_parent)
-                return m_parent->GetParent();
-            else
-                return NULL;
-        }
-        
-        virtual const ValueObject *
-        GetParent() const
-        {
-            if (m_parent)
-                return m_parent->GetParent();
-            else
-                return NULL;
-        }
-        
-        virtual lldb::ValueObjectSP
-        GetStaticValue ()
-        {
-            return m_parent->GetSP();
-        }
-        
-    protected:
-        virtual bool
-        UpdateValue ();
-        
-        virtual clang::ASTContext *
-        GetClangASTImpl ();
-        
-        virtual lldb::clang_type_t
-        GetClangTypeImpl ();
-        
-        ClangASTType m_cast_type;
-        
-    private:
-        ValueObjectCast (ValueObject &parent, 
-                         const ConstString &name, 
-                         const ClangASTType &cast_type);
-        
-        //------------------------------------------------------------------
-        // For ValueObject only
-        //------------------------------------------------------------------
-        DISALLOW_COPY_AND_ASSIGN (ValueObjectCast);
-    };
-
 //----------------------------------------------------------------------
 // A ValueObject that represents memory at a given address, viewed as some 
 // set lldb type.

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=166857&r1=166856&r2=166857&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Oct 26 21:05:48 2012
@@ -513,6 +513,7 @@
 		4CF52AF51428291E0051E832 /* SBFileSpecList.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CF52AF41428291E0051E832 /* SBFileSpecList.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		4CF52AF8142829390051E832 /* SBFileSpecList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CF52AF7142829390051E832 /* SBFileSpecList.cpp */; };
 		94031A9E13CF486700DCFF3C /* InputReaderEZ.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94031A9D13CF486600DCFF3C /* InputReaderEZ.cpp */; };
+		94094C6B163B6F840083A547 /* ValueObjectCast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94094C69163B6CD90083A547 /* ValueObjectCast.cpp */; };
 		9415F61813B2C0EF00A52B36 /* FormatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9415F61713B2C0EF00A52B36 /* FormatManager.cpp */; };
 		941BCC7F14E48C4000BB969C /* SBTypeFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 9461568614E355F2003A195C /* SBTypeFilter.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		941BCC8014E48C4000BB969C /* SBTypeFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 9461568714E355F2003A195C /* SBTypeFormat.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -1514,6 +1515,8 @@
 		94031A9B13CF484600DCFF3C /* InputReaderEZ.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = InputReaderEZ.h; path = include/lldb/Core/InputReaderEZ.h; sourceTree = "<group>"; };
 		94031A9D13CF486600DCFF3C /* InputReaderEZ.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InputReaderEZ.cpp; path = source/Core/InputReaderEZ.cpp; sourceTree = "<group>"; };
 		94031A9F13CF5B3D00DCFF3C /* PriorityPointerPair.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PriorityPointerPair.h; path = include/lldb/Utility/PriorityPointerPair.h; sourceTree = "<group>"; };
+		94094C68163B6CCC0083A547 /* ValueObjectCast.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectCast.h; path = include/lldb/Core/ValueObjectCast.h; sourceTree = "<group>"; };
+		94094C69163B6CD90083A547 /* ValueObjectCast.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectCast.cpp; path = source/Core/ValueObjectCast.cpp; sourceTree = "<group>"; };
 		9415F61613B2C0DC00A52B36 /* FormatManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = FormatManager.h; path = include/lldb/Core/FormatManager.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
 		9415F61713B2C0EF00A52B36 /* FormatManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = FormatManager.cpp; path = source/Core/FormatManager.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
 		9443B120140C18A90013457C /* SBData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBData.h; path = include/lldb/API/SBData.h; sourceTree = "<group>"; };
@@ -2599,6 +2602,8 @@
 				26BC7E9910F1B85900F91463 /* Value.cpp */,
 				26BC7D8210F1B77400F91463 /* ValueObject.h */,
 				26BC7E9A10F1B85900F91463 /* ValueObject.cpp */,
+				94094C68163B6CCC0083A547 /* ValueObjectCast.h */,
+				94094C69163B6CD90083A547 /* ValueObjectCast.cpp */,
 				26BC7D8310F1B77400F91463 /* ValueObjectChild.h */,
 				26BC7E9B10F1B85900F91463 /* ValueObjectChild.cpp */,
 				26424E3E125986D30016D82C /* ValueObjectConstResult.h */,
@@ -4161,6 +4166,7 @@
 				94CDEB9D15F0258500DD2A7A /* CXXFormatterFunctions.cpp in Sources */,
 				947A1D641616476B0017C8D1 /* CommandObjectPlugin.cpp in Sources */,
 				262ED0081631FA3A00879631 /* OptionGroupString.cpp in Sources */,
+				94094C6B163B6F840083A547 /* ValueObjectCast.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=166857&r1=166856&r2=166857&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Fri Oct 26 21:05:48 2012
@@ -24,6 +24,7 @@
 #include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/StreamString.h"
+#include "lldb/Core/ValueObjectCast.h"
 #include "lldb/Core/ValueObjectChild.h"
 #include "lldb/Core/ValueObjectConstResult.h"
 #include "lldb/Core/ValueObjectDynamicValue.h"

Added: lldb/trunk/source/Core/ValueObjectCast.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectCast.cpp?rev=166857&view=auto
==============================================================================
--- lldb/trunk/source/Core/ValueObjectCast.cpp (added)
+++ lldb/trunk/source/Core/ValueObjectCast.cpp Fri Oct 26 21:05:48 2012
@@ -0,0 +1,132 @@
+//===-- ValueObjectDynamicValue.cpp ---------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+#include "lldb/Core/ValueObjectCast.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ValueObjectList.h"
+#include "lldb/Core/Value.h"
+#include "lldb/Core/ValueObject.h"
+
+#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/Variable.h"
+
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+
+using namespace lldb_private;
+
+lldb::ValueObjectSP
+ValueObjectCast::Create (ValueObject &parent, 
+                         const ConstString &name, 
+                         const ClangASTType &cast_type)
+{
+    ValueObjectCast *cast_valobj_ptr = new ValueObjectCast (parent, name, cast_type);
+    return cast_valobj_ptr->GetSP();
+}
+
+ValueObjectCast::ValueObjectCast
+(
+    ValueObject &parent, 
+    const ConstString &name, 
+    const ClangASTType &cast_type
+) :
+    ValueObject(parent),
+    m_cast_type (cast_type)
+{
+    SetName (name);
+    m_value.SetContext (Value::eContextTypeClangType, cast_type.GetOpaqueQualType());
+}
+
+ValueObjectCast::~ValueObjectCast()
+{
+}
+
+lldb::clang_type_t
+ValueObjectCast::GetClangTypeImpl ()
+{
+    return m_cast_type.GetOpaqueQualType();
+}
+
+uint32_t
+ValueObjectCast::CalculateNumChildren()
+{
+    return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true);
+}
+
+clang::ASTContext *
+ValueObjectCast::GetClangASTImpl ()
+{
+    return m_cast_type.GetASTContext();
+}
+
+size_t
+ValueObjectCast::GetByteSize()
+{
+    return m_value.GetValueByteSize(GetClangAST(), NULL);
+}
+
+lldb::ValueType
+ValueObjectCast::GetValueType() const
+{
+    // Let our parent answer global, local, argument, etc...
+    return m_parent->GetValueType();
+}
+
+bool
+ValueObjectCast::UpdateValue ()
+{
+    SetValueIsValid (false);
+    m_error.Clear();
+    
+    if (m_parent->UpdateValueIfNeeded(false))
+    {
+        Value old_value(m_value);
+        m_update_point.SetUpdated();
+        m_value = m_parent->GetValue();
+        m_value.SetContext (Value::eContextTypeClangType, GetClangType());
+        SetAddressTypeOfChildren(m_parent->GetAddressTypeOfChildren());
+        if (ClangASTContext::IsAggregateType (GetClangType()))
+        {
+            // this value object represents an aggregate type whose
+            // children have values, but this object does not. So we
+            // say we are changed if our location has changed.
+            SetValueDidChange (m_value.GetValueType() != old_value.GetValueType() || m_value.GetScalar() != old_value.GetScalar());
+        } 
+        ExecutionContext exe_ctx (GetExecutionContextRef());
+        m_error = m_value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0, GetModule().get());
+        SetValueDidChange (m_parent->GetValueDidChange());
+        return true;
+    }
+    
+    // The dynamic value failed to get an error, pass the error along
+    if (m_error.Success() && m_parent->GetError().Fail())
+        m_error = m_parent->GetError();
+    SetValueIsValid (false);
+    return false;
+}
+
+bool
+ValueObjectCast::IsInScope ()
+{
+    return m_parent->IsInScope();
+}

Modified: lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectDynamicValue.cpp?rev=166857&r1=166856&r2=166857&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectDynamicValue.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectDynamicValue.cpp Fri Oct 26 21:05:48 2012
@@ -20,6 +20,7 @@
 #include "lldb/Core/Value.h"
 #include "lldb/Core/ValueObject.h"
 
+#include "lldb/Symbol/ClangASTType.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/Type.h"
@@ -32,112 +33,8 @@
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 
-
 using namespace lldb_private;
 
-lldb::ValueObjectSP
-ValueObjectCast::Create (ValueObject &parent, 
-                         const ConstString &name, 
-                         const ClangASTType &cast_type)
-{
-    ValueObjectCast *cast_valobj_ptr = new ValueObjectCast (parent, name, cast_type);
-    return cast_valobj_ptr->GetSP();
-}
-
-ValueObjectCast::ValueObjectCast
-(
-    ValueObject &parent, 
-    const ConstString &name, 
-    const ClangASTType &cast_type
-) :
-    ValueObject(parent),
-    m_cast_type (cast_type)
-{
-    SetName (name);
-    m_value.SetContext (Value::eContextTypeClangType, cast_type.GetOpaqueQualType());
-}
-
-ValueObjectCast::~ValueObjectCast()
-{
-}
-
-lldb::clang_type_t
-ValueObjectCast::GetClangTypeImpl ()
-{
-    return m_cast_type.GetOpaqueQualType();
-}
-
-uint32_t
-ValueObjectCast::CalculateNumChildren()
-{
-    return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true);
-}
-
-clang::ASTContext *
-ValueObjectCast::GetClangASTImpl ()
-{
-    return m_cast_type.GetASTContext();
-}
-
-size_t
-ValueObjectCast::GetByteSize()
-{
-    return m_value.GetValueByteSize(GetClangAST(), NULL);
-}
-
-lldb::ValueType
-ValueObjectCast::GetValueType() const
-{
-    // Let our parent answer global, local, argument, etc...
-    return m_parent->GetValueType();
-}
-
-bool
-ValueObjectCast::UpdateValue ()
-{
-    SetValueIsValid (false);
-    m_error.Clear();
-    
-    if (m_parent->UpdateValueIfNeeded(false))
-    {
-        Value old_value(m_value);
-        m_update_point.SetUpdated();
-        m_value = m_parent->GetValue();
-        m_value.SetContext (Value::eContextTypeClangType, GetClangType());
-        SetAddressTypeOfChildren(m_parent->GetAddressTypeOfChildren());
-        if (ClangASTContext::IsAggregateType (GetClangType()))
-        {
-            // this value object represents an aggregate type whose
-            // children have values, but this object does not. So we
-            // say we are changed if our location has changed.
-            SetValueDidChange (m_value.GetValueType() != old_value.GetValueType() || m_value.GetScalar() != old_value.GetScalar());
-        } 
-        ExecutionContext exe_ctx (GetExecutionContextRef());
-        m_error = m_value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0, GetModule().get());
-        SetValueDidChange (m_parent->GetValueDidChange());
-        return true;
-    }
-    
-    // The dynamic value failed to get an error, pass the error along
-    if (m_error.Success() && m_parent->GetError().Fail())
-        m_error = m_parent->GetError();
-    SetValueIsValid (false);
-    return false;
-}
-
-
-
-bool
-ValueObjectCast::IsInScope ()
-{
-    return m_parent->IsInScope();
-}
-
-//----------------------------------------------------------------------
-
-
-
-
 ValueObjectDynamicValue::ValueObjectDynamicValue (ValueObject &parent, lldb::DynamicValueType use_dynamic) :
     ValueObject(parent),
     m_address (),





More information about the lldb-commits mailing list