Switching back to using std::tr1::shared_ptr. We originally switched away
due to RTTI worries since llvm and clang don't use RTTI, but I was able to
switch back with no issues as far as I can tell. Once the RTTI issue wasn't
an issue, we were looking for a way to properly track weak pointers to objects
to solve some of the threading issues we have been running into which naturally
led us back to std::tr1::weak_ptr. We also wanted the ability to make a shared
pointer from just a pointer, which is also easily solved using the
std::tr1::enable_shared_from_this class.
The main reason for this move back is so we can start properly having weak
references to objects. Currently a lldb_private::Thread class has a refrence
to its parent lldb_private::Process. This doesn't work well when we now hand
out a SBThread object that contains a shared pointer to a lldb_private::Thread
as this SBThread can be held onto by external clients and if they end up
using one of these objects we can easily crash.
So the next task is to start adopting std::tr1::weak_ptr where ever it makes
sense which we can do with lldb_private::Debugger, lldb_private::Target,
lldb_private::Process, lldb_private::Thread, lldb_private::StackFrame, and
many more objects now that they are no longer using intrusive ref counted
pointer objects (you can't do std::tr1::weak_ptr functionality with intrusive
pointers).
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@149207 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangASTSource.cpp b/source/Expression/ClangASTSource.cpp
index d7a1926..162dfab 100644
--- a/source/Expression/ClangASTSource.cpp
+++ b/source/Expression/ClangASTSource.cpp
@@ -946,7 +946,7 @@
NamespaceDecl *
ClangASTSource::AddNamespace (NameSearchContext &context, ClangASTImporter::NamespaceMapSP &namespace_decls)
{
- if (namespace_decls.empty())
+ if (!namespace_decls)
return NULL;
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
diff --git a/source/Expression/ClangFunction.cpp b/source/Expression/ClangFunction.cpp
index c583da9..2244769 100644
--- a/source/Expression/ClangFunction.cpp
+++ b/source/Expression/ClangFunction.cpp
@@ -70,7 +70,7 @@
// Can't make a ClangFunction without a process.
assert (process != NULL);
- m_jit_process_sp = process->GetSP();
+ m_jit_process_sp = process->shared_from_this();
}
ClangFunction::ClangFunction
@@ -95,7 +95,7 @@
// Can't make a ClangFunction without a process.
assert (process != NULL);
- m_jit_process_sp = process->GetSP();
+ m_jit_process_sp = process->shared_from_this();
m_function_addr = m_function_ptr->GetAddressRange().GetBaseAddress();
m_function_return_qual_type = m_function_ptr->GetReturnClangType();
@@ -266,7 +266,7 @@
if (!jit_error.Success())
return false;
if (process && m_jit_alloc != LLDB_INVALID_ADDRESS)
- m_jit_process_sp = process->GetSP();
+ m_jit_process_sp = process->shared_from_this();
return true;
}
diff --git a/source/Expression/ClangUserExpression.cpp b/source/Expression/ClangUserExpression.cpp
index 7719f08..0bcae47 100644
--- a/source/Expression/ClangUserExpression.cpp
+++ b/source/Expression/ClangUserExpression.cpp
@@ -357,7 +357,7 @@
if (jit_error.Success())
{
if (process && m_jit_alloc != LLDB_INVALID_ADDRESS)
- m_jit_process_sp = process->GetSP();
+ m_jit_process_sp = process->shared_from_this();
return true;
}
else
diff --git a/source/Expression/ClangUtilityFunction.cpp b/source/Expression/ClangUtilityFunction.cpp
index 7220be8..78c3c16 100644
--- a/source/Expression/ClangUtilityFunction.cpp
+++ b/source/Expression/ClangUtilityFunction.cpp
@@ -148,7 +148,7 @@
}
if (m_jit_start_addr != LLDB_INVALID_ADDRESS)
- m_jit_process_sp = process->GetSP();
+ m_jit_process_sp = process->shared_from_this();
#if 0
// jingham: look here
diff --git a/source/Expression/IRInterpreter.cpp b/source/Expression/IRInterpreter.cpp
index 3cbe9f3..a7ca4c8 100644
--- a/source/Expression/IRInterpreter.cpp
+++ b/source/Expression/IRInterpreter.cpp
@@ -69,8 +69,8 @@
return s;
}
-typedef lldb::SharedPtr <lldb_private::DataEncoder>::Type DataEncoderSP;
-typedef lldb::SharedPtr <lldb_private::DataExtractor>::Type DataExtractorSP;
+typedef SHARED_PTR(lldb_private::DataEncoder) DataEncoderSP;
+typedef SHARED_PTR(lldb_private::DataExtractor) DataExtractorSP;
class Memory
{
@@ -127,7 +127,7 @@
}
};
- typedef lldb::SharedPtr <Allocation>::Type AllocationSP;
+ typedef SHARED_PTR(Allocation) AllocationSP;
struct Region
{