Strengthened LLDB's completion of object types.
Now when LLDB reports a variable, it has a
complete type. Similarly, when it reports
members of a struct, it completes their types.
Also, when it creates the result variable for
an expression, it ensures that variable's type
is complete.
This ensures compliance with Clang's
expectations, preventing potential crashes.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@152771 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ASTResultSynthesizer.cpp b/source/Expression/ASTResultSynthesizer.cpp
index de17ebd..2c75338 100644
--- a/source/Expression/ASTResultSynthesizer.cpp
+++ b/source/Expression/ASTResultSynthesizer.cpp
@@ -16,6 +16,7 @@
#include "clang/AST/Expr.h"
#include "clang/AST/Stmt.h"
#include "clang/Parse/Parser.h"
+#include "clang/Sema/SemaDiagnostic.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/raw_ostream.h"
#include "lldb/Core/Log.h"
@@ -329,8 +330,10 @@
else
result_ptr_id = &Ctx.Idents.get("$__lldb_expr_result_ptr");
- QualType ptr_qual_type;
+ m_sema->RequireCompleteType(SourceLocation(), expr_qual_type, clang::diag::err_incomplete_type);
+ QualType ptr_qual_type;
+
if (expr_qual_type->getAs<ObjCObjectType>() != NULL)
ptr_qual_type = Ctx.getObjCObjectPointerType(expr_qual_type);
else
diff --git a/source/Expression/ClangASTSource.cpp b/source/Expression/ClangASTSource.cpp
index 593b617..bfe876d 100644
--- a/source/Expression/ClangASTSource.cpp
+++ b/source/Expression/ClangASTSource.cpp
@@ -387,6 +387,17 @@
Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, original_ctx, decl);
+ if (FieldDecl *copied_field = dyn_cast<FieldDecl>(copied_decl))
+ {
+ QualType copied_field_type = copied_field->getType();
+
+ if (const TagType *copied_field_tag_type = copied_field_type->getAs<TagType>())
+ m_ast_importer->CompleteTagDecl(copied_field_tag_type->getDecl());
+ if (const ObjCObjectType *copied_field_object_type = copied_field_type->getAs<ObjCObjectType>())
+ if (ObjCInterfaceDecl *copied_field_objc_interface_decl = copied_field_object_type->getInterface())
+ m_ast_importer->CompleteObjCInterfaceDecl(copied_field_objc_interface_decl);
+ }
+
decls.push_back(copied_decl);
}
}
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index 1f46ff0..ccb5266 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -2900,6 +2900,14 @@
&ut,
&pt);
+ clang::QualType parser_opaque_type = QualType::getFromOpaquePtr(pt.GetOpaqueQualType());
+
+ if (const clang::Type *parser_type = parser_opaque_type.getTypePtr())
+ {
+ if (const TagType *tag_type = dyn_cast<TagType>(parser_type))
+ CompleteType(tag_type->getDecl());
+ }
+
if (!var_location)
return;