Added support for finding and global variables in the SBTarget and SBModule
level in the public API. 

Also modified the ValueObject values to be able to display global variables
without having a valid running process. The globals will read themselves from
the object file section data if there is no process, and from the process if
there is one.

Also fixed an issue where modifications for dynamic types could cause child
values of ValueObjects to not show up if the value was unable to evaluate
itself (children of NULL pointer objects).

llvm-svn: 134102
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index b692ae5..fb55a51 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -4046,6 +4046,150 @@
 }
 
 bool
+ClangASTContext::IsPossibleDynamicType (clang::ASTContext *ast, clang_type_t clang_type, clang_type_t *dynamic_pointee_type)
+{
+    QualType pointee_qual_type;
+    if (clang_type)
+    {
+        QualType qual_type (QualType::getFromOpaquePtr(clang_type));
+        const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+        bool success = false;
+        switch (type_class)
+        {
+            case clang::Type::Builtin:
+                if (cast<clang::BuiltinType>(qual_type)->getKind() == clang::BuiltinType::ObjCId)
+                {
+                    if (dynamic_pointee_type)
+                        *dynamic_pointee_type = clang_type;
+                    return true;
+                }
+                break;
+
+            case clang::Type::ObjCObjectPointer:
+                if (dynamic_pointee_type)
+                    *dynamic_pointee_type = cast<ObjCObjectPointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
+                return true;
+
+            case clang::Type::Pointer:
+                pointee_qual_type = cast<PointerType>(qual_type)->getPointeeType();
+                success = true;
+                break;
+                
+            case clang::Type::LValueReference:
+            case clang::Type::RValueReference:
+                pointee_qual_type = cast<ReferenceType>(qual_type)->getPointeeType();
+                success = true;
+                break;
+                
+            case clang::Type::Typedef:
+                return ClangASTContext::IsPossibleCPlusPlusDynamicType (ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), dynamic_pointee_type);
+                
+            default:
+                break;
+        }
+        
+        if (success)
+        {
+            // Check to make sure what we are pointing too is a possible dynamic C++ type
+            // We currently accept any "void *" (in case we have a class that has been
+            // watered down to an opaque pointer) and virtual C++ classes.
+            const clang::Type::TypeClass pointee_type_class = pointee_qual_type->getTypeClass();
+            switch (pointee_type_class)
+            {
+                case clang::Type::Builtin:
+                    switch (cast<clang::BuiltinType>(pointee_qual_type)->getKind())
+                    {
+                        case clang::BuiltinType::UnknownAny:
+                        case clang::BuiltinType::Void:
+                            if (dynamic_pointee_type)
+                                *dynamic_pointee_type = pointee_qual_type.getAsOpaquePtr();
+                            return true;
+                            
+                        case clang::BuiltinType::NullPtr:  
+                        case clang::BuiltinType::Bool:
+                        case clang::BuiltinType::Char_U:
+                        case clang::BuiltinType::UChar:
+                        case clang::BuiltinType::WChar_U:
+                        case clang::BuiltinType::Char16:
+                        case clang::BuiltinType::Char32:
+                        case clang::BuiltinType::UShort:
+                        case clang::BuiltinType::UInt:
+                        case clang::BuiltinType::ULong:
+                        case clang::BuiltinType::ULongLong:
+                        case clang::BuiltinType::UInt128:
+                        case clang::BuiltinType::Char_S:
+                        case clang::BuiltinType::SChar:
+                        case clang::BuiltinType::WChar_S:
+                        case clang::BuiltinType::Short:
+                        case clang::BuiltinType::Int:
+                        case clang::BuiltinType::Long:
+                        case clang::BuiltinType::LongLong:
+                        case clang::BuiltinType::Int128:
+                        case clang::BuiltinType::Float:
+                        case clang::BuiltinType::Double:
+                        case clang::BuiltinType::LongDouble:
+                        case clang::BuiltinType::Dependent:
+                        case clang::BuiltinType::Overload:
+                        case clang::BuiltinType::ObjCId:
+                        case clang::BuiltinType::ObjCClass:
+                        case clang::BuiltinType::ObjCSel:
+                        case clang::BuiltinType::BoundMember:
+                            break;
+                    }
+                    break;
+
+                case clang::Type::Record:
+                    {
+                        CXXRecordDecl *cxx_record_decl = pointee_qual_type->getAsCXXRecordDecl();
+                        if (cxx_record_decl)
+                        {
+                            if (GetCompleteQualType (ast, pointee_qual_type))
+                            {
+                                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;
+                            }
+                            if (success)
+                            {
+                                if (dynamic_pointee_type)
+                                    *dynamic_pointee_type = pointee_qual_type.getAsOpaquePtr();
+                                return true;
+                            }
+                        }
+                    }
+                    break;
+                    
+                case clang::Type::ObjCObject:
+                case clang::Type::ObjCInterface:
+                    {
+                        const clang::ObjCObjectType *objc_class_type = pointee_qual_type->getAsObjCQualifiedInterfaceType();
+                        if (objc_class_type)
+                        {
+                            GetCompleteQualType (ast, pointee_qual_type);
+                            if (dynamic_pointee_type)
+                                *dynamic_pointee_type = pointee_qual_type.getAsOpaquePtr();
+                            return true;
+                        }
+                    }
+                    break;
+
+                default:
+                    break;
+            }
+        }
+    }
+    if (dynamic_pointee_type)
+        *dynamic_pointee_type = NULL;
+    return false;
+}
+
+
+bool
 ClangASTContext::IsPossibleCPlusPlusDynamicType (clang::ASTContext *ast, clang_type_t clang_type, clang_type_t *dynamic_pointee_type)
 {
     QualType pointee_qual_type;