summaryrefslogtreecommitdiffstats
path: root/lldb
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2012-08-31 18:56:24 +0000
committerGreg Clayton <gclayton@apple.com>2012-08-31 18:56:24 +0000
commit7036425c59000b63662b70dab35f691eb8f10a40 (patch)
treeb4edd51d4086d88f49759f4fb5605371d92933ab /lldb
parentdc86f94f623b285b61192cf1a1ca8daa87d28422 (diff)
downloadbcm5719-llvm-7036425c59000b63662b70dab35f691eb8f10a40.tar.gz
bcm5719-llvm-7036425c59000b63662b70dab35f691eb8f10a40.zip
<rdar://problem/12202862>
Added a fix for incorrect dynamic typing. Before when asking if a C++ class could be dynamic, we would answer yes for incomplete C++ classes. This turned out to have issues where if a class was not virtual, yet had its first ivar be an instance of a virtual class, we would incorrectly say that a class was virtual and we would downcast it to be a pointer to the first ivar. We now ask the class to complete itself prior to answering the question. We need to test the effects on memory of this change prior to submission. It is the safest and best fix, but it does have a potential downside of higher memory consumption. llvm-svn: 163014
Diffstat (limited to 'lldb')
-rw-r--r--lldb/include/lldb/Symbol/ClangASTContext.h6
-rw-r--r--lldb/source/Core/ValueObject.cpp2
-rw-r--r--lldb/source/Symbol/ClangASTContext.cpp30
3 files changed, 21 insertions, 17 deletions
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h
index 67e907ee27d..b99cf5576ff 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -868,9 +868,9 @@ public:
static bool
IsPossibleDynamicType (clang::ASTContext *ast,
lldb::clang_type_t clang_type,
- lldb::clang_type_t *dynamic_pointee_type = NULL,
- bool cplusplus = true,
- bool objc = true);
+ lldb::clang_type_t *dynamic_pointee_type, // Can pass NULL
+ bool check_cplusplus,
+ bool check_objc);
static bool
IsCStringType (lldb::clang_type_t clang_type, uint32_t &length);
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index ed370e66c12..c613965087e 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -1784,7 +1784,7 @@ ValueObject::IsPossibleDynamicType ()
if (process)
return process->IsPossibleDynamicValue(*this);
else
- return ClangASTContext::IsPossibleDynamicType (GetClangAST (), GetClangType());
+ return ClangASTContext::IsPossibleDynamicType (GetClangAST (), GetClangType(), NULL, true, true);
}
ValueObjectSP
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index 132ab60b34a..c5ad4972f6d 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -5522,10 +5522,18 @@ ClangASTContext::IsPossibleDynamicType (clang::ASTContext *ast,
break;
case clang::Type::Typedef:
- return ClangASTContext::IsPossibleDynamicType (ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), dynamic_pointee_type);
+ return ClangASTContext::IsPossibleDynamicType (ast,
+ cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
+ dynamic_pointee_type,
+ check_cplusplus,
+ check_objc);
case clang::Type::Elaborated:
- return ClangASTContext::IsPossibleDynamicType (ast, cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(), dynamic_pointee_type);
+ return ClangASTContext::IsPossibleDynamicType (ast,
+ cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(),
+ dynamic_pointee_type,
+ check_cplusplus,
+ check_objc);
default:
break;
@@ -5590,23 +5598,19 @@ ClangASTContext::IsPossibleDynamicType (clang::ASTContext *ast,
CXXRecordDecl *cxx_record_decl = pointee_qual_type->getAsCXXRecordDecl();
if (cxx_record_decl)
{
- // Do NOT complete the type here like we used to do
- // otherwise EVERY "class *" variable we have will try
- // to fully complete itself and this will take a lot of
- // time, memory and slow down debugging. If we have a complete
- // type, then answer the question definitively, else we
- // just say that a C++ class can possibly be dynamic...
- if (cxx_record_decl->isCompleteDefinition())
+ bool is_complete = cxx_record_decl->isCompleteDefinition();
+ if (!is_complete)
+ is_complete = ClangASTContext::GetCompleteType (ast, clang_type);
+
+ if (is_complete)
{
success = cxx_record_decl->isDynamicClass();
}
else
{
- // We failed to get the complete type, so we have to
- // treat this as a void * which we might possibly be
- // able to complete
- success = true;
+ success = false;
}
+
if (success)
{
if (dynamic_pointee_type)
OpenPOWER on IntegriCloud