[Lldb-commits] [lldb] r152771 - in /lldb/trunk/source/Expression: ASTResultSynthesizer.cpp ClangASTSource.cpp ClangExpressionDeclMap.cpp

Sean Callanan scallanan at apple.com
Wed Mar 14 18:53:17 PDT 2012


Author: spyffe
Date: Wed Mar 14 20:53:17 2012
New Revision: 152771

URL: http://llvm.org/viewvc/llvm-project?rev=152771&view=rev
Log:
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.

Modified:
    lldb/trunk/source/Expression/ASTResultSynthesizer.cpp
    lldb/trunk/source/Expression/ClangASTSource.cpp
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp

Modified: lldb/trunk/source/Expression/ASTResultSynthesizer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTResultSynthesizer.cpp?rev=152771&r1=152770&r2=152771&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ASTResultSynthesizer.cpp (original)
+++ lldb/trunk/source/Expression/ASTResultSynthesizer.cpp Wed Mar 14 20:53:17 2012
@@ -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

Modified: lldb/trunk/source/Expression/ClangASTSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=152771&r1=152770&r2=152771&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangASTSource.cpp (original)
+++ lldb/trunk/source/Expression/ClangASTSource.cpp Wed Mar 14 20:53:17 2012
@@ -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);
         }
     }

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=152771&r1=152770&r2=152771&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Wed Mar 14 20:53:17 2012
@@ -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;
     





More information about the lldb-commits mailing list