Added support for accessing members of C++ objects,
including superclass members.  This involved ensuring
that access control was ignored, and ensuring that
the operands of BitCasts were properly scanned for
variables that needed importing.

Also laid the groundwork for declaring objects of
custom types; however, this functionality is disabled
for now because of a potential loop in ASTImporter.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@110174 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangASTSource.cpp b/source/Expression/ClangASTSource.cpp
index 3f83acf..f914728 100644
--- a/source/Expression/ClangASTSource.cpp
+++ b/source/Expression/ClangASTSource.cpp
@@ -162,3 +162,22 @@
 
     return AddFunDecl(generic_function_type.getAsOpaquePtr());
 }
+
+clang::NamedDecl *NameSearchContext::AddTypeDecl(void *type)
+{
+    QualType QT = QualType::getFromOpaquePtr(type);
+    clang::Type *T = QT.getTypePtr();
+
+    if (TagType *tag_type = dyn_cast<clang::TagType>(T))
+    {
+        TagDecl *tag_decl = tag_type->getDecl();
+        
+        Decls.push_back(tag_decl);
+        
+        return tag_decl;
+    }
+    else
+    {
+        return NULL;
+    }
+}
diff --git a/source/Expression/ClangExpression.cpp b/source/Expression/ClangExpression.cpp
index 0ff4c38..0e103b6 100644
--- a/source/Expression/ClangExpression.cpp
+++ b/source/Expression/ClangExpression.cpp
@@ -238,6 +238,7 @@
     m_clang_ap->getLangOpts().CPlusPlus = true;
     m_clang_ap->getLangOpts().ObjC1 = true;
     m_clang_ap->getLangOpts().ThreadsafeStatics = false;
+    m_clang_ap->getLangOpts().AccessControl = false; // Debuggers get universal access
     
     // Set CodeGen options
     m_clang_ap->getCodeGenOpts().EmitDeclMetadata = true;
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index ff54250..60b23c8 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -679,6 +679,13 @@
     
     if (var)
         AddOneVariable(context, var);
+    
+    /* Commented out pending resolution of a loop when the TagType is imported
+    lldb::TypeSP type = m_sym_ctx->FindTypeByName(name_cs);
+    
+    if (type.get())
+        AddOneType(context, type.get());
+    */
 }
         
 Value *
@@ -886,3 +893,15 @@
     if (log)
         log->Printf("Found function %s, returned (NamedDecl)%p", context.Name.getAsString().c_str(), fun_decl);    
 }
+
+void 
+ClangExpressionDeclMap::AddOneType(NameSearchContext &context, 
+                                   Type *type)
+{
+    TypeFromUser ut(type->GetOpaqueClangQualType(),
+                    type->GetClangAST());
+    
+    void *copied_type = ClangASTContext::CopyType(context.GetASTContext(), ut.GetASTContext(), ut.GetOpaqueQualType());
+    
+    context.AddTypeDecl(copied_type);
+}
diff --git a/source/Expression/IRForTarget.cpp b/source/Expression/IRForTarget.cpp
index 63752e1..4f3a740 100644
--- a/source/Expression/IRForTarget.cpp
+++ b/source/Expression/IRForTarget.cpp
@@ -249,8 +249,12 @@
 
     if (ConstantExpr *constant_expr = dyn_cast<ConstantExpr>(V))
     {
-        if (constant_expr->getOpcode() == Instruction::GetElementPtr)
+        switch (constant_expr->getOpcode())
         {
+        default:
+            break;
+        case Instruction::GetElementPtr:
+        case Instruction::BitCast:
             Value *s = constant_expr->getOperand(0);
             MaybeHandleVariable(M, s, Store);
         }
diff --git a/source/Symbol/SymbolContext.cpp b/source/Symbol/SymbolContext.cpp
index a045d18..ff2ce87 100644
--- a/source/Symbol/SymbolContext.cpp
+++ b/source/Symbol/SymbolContext.cpp
@@ -403,9 +403,18 @@
 }
 
 lldb::TypeSP
-SymbolContext::FindTypeByName (const char *name) const
+SymbolContext::FindTypeByName (const ConstString &name) const
 {
     lldb::TypeSP return_value;
+        
+    TypeList types;
+    
+    if (module_sp && module_sp->FindTypes (*this, name, false, 1, types))
+        return types.GetTypeAtIndex(0);
+    
+    if (!return_value.get() && target_sp && target_sp->GetImages().FindTypes (*this, name, false, 1, types))
+        return types.GetTypeAtIndex(0);
+    
     return return_value;
 }