[Lldb-commits] [lldb] r123613 - in /lldb/trunk: include/lldb/ include/lldb/API/ include/lldb/Core/ include/lldb/Expression/ include/lldb/Symbol/ lldb.xcodeproj/ source/API/ source/Commands/ source/Core/ source/Expression/ source/Interpreter/ source/Plugins/Disassembler/llvm/ source/Plugins/Process/gdb-remote/ source/Plugins/SymbolFile/DWARF/ source/Symbol/ source/Target/ test/class_types/

Greg Clayton gclayton at apple.com
Sun Jan 16 19:46:26 PST 2011


Author: gclayton
Date: Sun Jan 16 21:46:26 2011
New Revision: 123613

URL: http://llvm.org/viewvc/llvm-project?rev=123613&view=rev
Log:
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a 
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.

A few months ago I worked with the llvm/clang folks to have the 
ExternalASTSource class be able to complete classes if there weren't completed
yet:

class ExternalASTSource {
....

    virtual void
    CompleteType (clang::TagDecl *Tag);
    
    virtual void 
    CompleteType (clang::ObjCInterfaceDecl *Class);
};

This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.

This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
  objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
  types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
  ClangASTType, and more) can now be iterating through children of any type,
  and if a class/union/struct type (clang::RecordType or ObjC interface) 
  is found that is incomplete, we can ask the AST to get the definition. 
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
  all child SymbolFileDWARF classes will share (much like what happens when
  we have a complete linked DWARF for an executable).
  
We will need to modify some of the ClangUserExpression code to take more 
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.


Modified:
    lldb/trunk/include/lldb/API/SBValue.h
    lldb/trunk/include/lldb/Core/Module.h
    lldb/trunk/include/lldb/Core/ValueObject.h
    lldb/trunk/include/lldb/Core/ValueObjectChild.h
    lldb/trunk/include/lldb/Core/ValueObjectConstResult.h
    lldb/trunk/include/lldb/Core/ValueObjectRegister.h
    lldb/trunk/include/lldb/Core/ValueObjectVariable.h
    lldb/trunk/include/lldb/Expression/ClangASTSource.h
    lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
    lldb/trunk/include/lldb/Symbol/ClangASTContext.h
    lldb/trunk/include/lldb/Symbol/SymbolFile.h
    lldb/trunk/include/lldb/Symbol/TaggedASTType.h
    lldb/trunk/include/lldb/Symbol/Type.h
    lldb/trunk/include/lldb/Symbol/TypeList.h
    lldb/trunk/include/lldb/lldb-forward.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/API/SBType.cpp
    lldb/trunk/source/API/SBValue.cpp
    lldb/trunk/source/Commands/CommandObjectArgs.cpp
    lldb/trunk/source/Core/Module.cpp
    lldb/trunk/source/Core/ValueObject.cpp
    lldb/trunk/source/Core/ValueObjectChild.cpp
    lldb/trunk/source/Core/ValueObjectConstResult.cpp
    lldb/trunk/source/Core/ValueObjectRegister.cpp
    lldb/trunk/source/Core/ValueObjectVariable.cpp
    lldb/trunk/source/Expression/ClangASTSource.cpp
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
    lldb/trunk/source/Interpreter/CommandInterpreter.cpp
    lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
    lldb/trunk/source/Symbol/ClangASTContext.cpp
    lldb/trunk/source/Symbol/ClangASTType.cpp
    lldb/trunk/source/Symbol/SymbolFile.cpp
    lldb/trunk/source/Symbol/SymbolVendor.cpp
    lldb/trunk/source/Symbol/Type.cpp
    lldb/trunk/source/Symbol/TypeList.cpp
    lldb/trunk/source/Target/StackFrame.cpp
    lldb/trunk/source/Target/ThreadPlanTracer.cpp
    lldb/trunk/test/class_types/TestClassTypes.py

Modified: lldb/trunk/include/lldb/API/SBValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBValue.h (original)
+++ lldb/trunk/include/lldb/API/SBValue.h Sun Jan 16 21:46:26 2011
@@ -106,6 +106,9 @@
 
     bool
     GetExpressionPath (lldb::SBStream &description);
+    
+    bool
+    GetExpressionPath (lldb::SBStream &description, bool qualify_cxx_base_classes);
 
 protected:
     friend class SBValueList;

Modified: lldb/trunk/include/lldb/Core/Module.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Sun Jan 16 21:46:26 2011
@@ -16,6 +16,7 @@
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Host/Mutex.h"
 #include "lldb/Host/TimeValue.h"
+#include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/Symtab.h"
@@ -561,6 +562,9 @@
         m_is_dynamic_loader_module = b;
     }
     
+    ClangASTContext &
+    GetClangASTContext ();
+
 protected:
     //------------------------------------------------------------------
     // Member Variables
@@ -573,9 +577,11 @@
     ConstString                 m_object_name;  ///< The name an object within this module that is selected, or empty of the module is represented by \a m_file.
     std::auto_ptr<ObjectFile>   m_objfile_ap;   ///< A pointer to the object file parser for this module.
     std::auto_ptr<SymbolVendor> m_symfile_ap;   ///< A pointer to the symbol vendor for this module.
+    ClangASTContext             m_ast;          ///< The AST context for this module.
     bool                        m_did_load_objfile:1,
                                 m_did_load_symbol_vendor:1,
                                 m_did_parse_uuid:1,
+                                m_did_init_ast:1,
                                 m_is_dynamic_loader_module:1;
     
     //------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Sun Jan 16 21:46:26 2011
@@ -44,7 +44,7 @@
     virtual clang::ASTContext *
     GetClangAST () = 0;
 
-    virtual void *
+    virtual lldb::clang_type_t
     GetClangType () = 0;
 
     virtual lldb::ValueType
@@ -88,7 +88,7 @@
     }
 
     virtual void
-    GetExpressionPath (Stream &s);
+    GetExpressionPath (Stream &s, bool qualify_cxx_base_classes);
 
     virtual bool
     IsInScope (StackFrame *frame)

Modified: lldb/trunk/include/lldb/Core/ValueObjectChild.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectChild.h?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectChild.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectChild.h Sun Jan 16 21:46:26 2011
@@ -67,7 +67,7 @@
         return m_clang_ast;
     }
 
-    virtual void *
+    virtual lldb::clang_type_t
     GetClangType ()
     {
         return m_clang_type;

Modified: lldb/trunk/include/lldb/Core/ValueObjectConstResult.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectConstResult.h?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectConstResult.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectConstResult.h Sun Jan 16 21:46:26 2011
@@ -57,7 +57,7 @@
     virtual clang::ASTContext *
     GetClangAST ();
 
-    virtual void *
+    virtual lldb::clang_type_t
     GetClangType ();
 
     virtual lldb::ValueType

Modified: lldb/trunk/include/lldb/Core/ValueObjectRegister.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectRegister.h?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectRegister.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectRegister.h Sun Jan 16 21:46:26 2011
@@ -37,7 +37,7 @@
     virtual clang::ASTContext *
     GetClangAST ();
 
-    virtual void *
+    virtual lldb::clang_type_t
     GetClangType ();
 
     virtual lldb::ValueType
@@ -82,7 +82,7 @@
     virtual clang::ASTContext *
     GetClangAST ();
 
-    virtual void *
+    virtual lldb::clang_type_t
     GetClangType ();
 
     virtual lldb::ValueType
@@ -130,7 +130,7 @@
     virtual clang::ASTContext *
     GetClangAST ();
 
-    virtual void *
+    virtual lldb::clang_type_t
     GetClangType ();
 
     virtual lldb::ValueType

Modified: lldb/trunk/include/lldb/Core/ValueObjectVariable.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectVariable.h?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectVariable.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectVariable.h Sun Jan 16 21:46:26 2011
@@ -36,7 +36,7 @@
     virtual clang::ASTContext *
     GetClangAST ();
 
-    virtual void *
+    virtual lldb::clang_type_t
     GetClangType ();
 
     virtual ConstString

Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangASTSource.h?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangASTSource.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangASTSource.h Sun Jan 16 21:46:26 2011
@@ -13,7 +13,7 @@
 #include <set>
 
 #include "clang/Basic/IdentifierTable.h"
-#include "clang/Sema/ExternalSemaSource.h"
+#include "clang/AST/ExternalASTSource.h"
 
 namespace lldb_private {
     
@@ -30,7 +30,7 @@
 /// to Clang for these names, consulting the ClangExpressionDeclMap to do
 /// the actual lookups.
 //----------------------------------------------------------------------
-class ClangASTSource : public clang::ExternalSemaSource 
+class ClangASTSource : public clang::ExternalASTSource 
 {
 public:
     //------------------------------------------------------------------
@@ -44,8 +44,8 @@
     /// @param[in] declMap
     ///     A reference to the LLDB object that handles entity lookup.
     //------------------------------------------------------------------
-	ClangASTSource(clang::ASTContext &context,
-                   ClangExpressionDeclMap &decl_map) : 
+	ClangASTSource (clang::ASTContext &context,
+                    ClangExpressionDeclMap &decl_map) : 
         m_ast_context (context),
         m_decl_map (decl_map),
         m_active_lookups ()
@@ -60,27 +60,59 @@
     //------------------------------------------------------------------
     /// Interface stub that returns NULL.
     //------------------------------------------------------------------
-    clang::Decl *GetExternalDecl(uint32_t);
+    virtual clang::Decl *
+    GetExternalDecl(uint32_t)
+    {
+        // These are only required for AST source that want to lazily load
+        // the declarations (or parts thereof) that they return.
+        return NULL;
+    }
     
     //------------------------------------------------------------------
     /// Interface stub that returns NULL.
     //------------------------------------------------------------------
-    clang::Stmt *GetExternalDeclStmt(uint64_t);
+    virtual clang::Stmt *
+    GetExternalDeclStmt(uint64_t)
+    {
+        // These are only required for AST source that want to lazily load
+        // the declarations (or parts thereof) that they return.
+        return NULL;
+    }
 	
     //------------------------------------------------------------------
     /// Interface stub that returns an undifferentiated Selector.
     //------------------------------------------------------------------
-    clang::Selector GetExternalSelector(uint32_t);
+    virtual clang::Selector 
+    GetExternalSelector(uint32_t)
+    {
+        // These are also optional, although it might help with ObjC
+        // debugging if we have respectable signatures.  But a more
+        // efficient interface (that didn't require scanning all files
+        // for method signatures!) might help.
+        return clang::Selector();
+    }
     
     //------------------------------------------------------------------
     /// Interface stub that returns 0.
     //------------------------------------------------------------------
-	uint32_t GetNumExternalSelectors();
+	virtual uint32_t
+    GetNumExternalSelectors()
+    {
+        // These are also optional, although it might help with ObjC
+        // debugging if we have respectable signatures.  But a more
+        // efficient interface (that didn't require scanning all files
+        // for method signatures!) might help.
+        return 0;
+    }
     
     //------------------------------------------------------------------
     /// Interface stub that returns NULL.
     //------------------------------------------------------------------
-    clang::CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset);
+    virtual clang::CXXBaseSpecifier *
+    GetExternalCXXBaseSpecifiers(uint64_t Offset)
+    {
+        return NULL;
+    }
 	
     //------------------------------------------------------------------
     /// Look up all Decls that match a particular name.  Only handles
@@ -96,22 +128,31 @@
     /// @return
     ///     Whatever SetExternalVisibleDeclsForName returns.
     //------------------------------------------------------------------
-    clang::DeclContextLookupResult 
+    virtual clang::DeclContextLookupResult 
     FindExternalVisibleDeclsByName (const clang::DeclContext *DC,
                                     clang::DeclarationName Name);
     
     //------------------------------------------------------------------
     /// Interface stub.
     //------------------------------------------------------------------
-    void MaterializeVisibleDecls (const clang::DeclContext *DC);
+    virtual void 
+    MaterializeVisibleDecls (const clang::DeclContext *DC);
 	
     //------------------------------------------------------------------
     /// Interface stub that returns true.
     //------------------------------------------------------------------
-	bool FindExternalLexicalDecls (const clang::DeclContext *DC,
-                                   bool (*isKindWeWant)(clang::Decl::Kind),
-                                   llvm::SmallVectorImpl<clang::Decl*> &Decls);
+	virtual bool 
+    FindExternalLexicalDecls (const clang::DeclContext *DC,
+                              bool (*isKindWeWant)(clang::Decl::Kind),
+                              llvm::SmallVectorImpl<clang::Decl*> &Decls);
     
+    
+    virtual void
+    CompleteType (clang::TagDecl *Tag);
+    
+    virtual void 
+    CompleteType (clang::ObjCInterfaceDecl *Class);
+
     //------------------------------------------------------------------
     /// Called on entering a translation unit.  Tells Clang by calling
     /// setHasExternalVisibleStorage() and setHasExternalLexicalStorage()

Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Sun Jan 16 21:46:26 2011
@@ -20,6 +20,7 @@
 // Other libraries and framework includes
 // Project includes
 #include "llvm/ADT/DenseMap.h"
+#include "lldb/lldb-include.h"
 #include "lldb/Core/ClangForward.h"
 #include "lldb/Core/Value.h"
 #include "lldb/Expression/ClangExpressionVariable.h"
@@ -27,20 +28,8 @@
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/ExecutionContext.h"
 
-namespace llvm {
-    class Type;
-    class Value;
-}
-
 namespace lldb_private {
 
-class ClangExpressionVariables;
-class ClangPersistentVariables;
-class Error;
-class Function;
-class NameSearchContext;
-class Variable;
-
 //----------------------------------------------------------------------
 /// @class ClangExpressionDeclMap ClangExpressionDeclMap.h "lldb/Expression/ClangExpressionDeclMap.h"
 /// @brief Manages named entities that are defined in LLDB's debug information.
@@ -430,11 +419,19 @@
     ///     True if a $__lldb variable has been found.
     //------------------------------------------------------------------
     bool
-    GetLookupsEnabled ()
+    GetLookupsEnabled () const
     {
         assert(m_parser_vars.get());
         return m_parser_vars->m_enable_lookups;
     }
+
+    bool
+    GetImportInProgress () const
+    {
+        if (m_parser_vars.get())
+            return m_parser_vars->m_ignore_lookups;
+        return false;
+    }
     
     //------------------------------------------------------------------
     /// [Used by ClangASTSource] Indicate that a $__lldb variable has

Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Sun Jan 16 21:46:26 2011
@@ -18,6 +18,8 @@
 #include <stdint.h>
 
 // Other libraries and framework includes
+#include "llvm/ADT/OwningPtr.h"
+
 // Project includes
 #include "lldb/lldb-enumerations.h"
 #include "lldb/Core/ClangForward.h"
@@ -50,10 +52,13 @@
         eTypeIsVector           = (1u << 16)
     };
 
+    typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *);
+    typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton, clang::ObjCInterfaceDecl *);
+
     //------------------------------------------------------------------
     // Constructors and Destructors
     //------------------------------------------------------------------
-    ClangASTContext(const char *target_triple);
+    ClangASTContext (const char *triple = NULL);
 
     ~ClangASTContext();
 
@@ -99,6 +104,22 @@
     void
     SetTargetTriple (const char *target_triple);
 
+    bool
+    HasExternalSource ();
+
+    void
+    SetExternalSource (llvm::OwningPtr<clang::ExternalASTSource> &ast_source_ap);
+
+    void
+    RemoveExternalSource ();
+
+    bool
+    GetCompleteType (lldb::clang_type_t clang_type);
+    
+    static bool
+    GetCompleteType (clang::ASTContext *ast,
+                     lldb::clang_type_t clang_type);
+
     //------------------------------------------------------------------
     // Basic Types
     //------------------------------------------------------------------
@@ -108,7 +129,7 @@
                                           uint32_t bit_size);
     
     static lldb::clang_type_t
-    GetBuiltinTypeForEncodingAndBitSize (clang::ASTContext *ast_context,
+    GetBuiltinTypeForEncodingAndBitSize (clang::ASTContext *ast,
                                          lldb::Encoding encoding,
                                          uint32_t bit_size);
 
@@ -119,7 +140,7 @@
         uint32_t bit_size);
 
     static lldb::clang_type_t
-    GetBuiltInType_void(clang::ASTContext *ast_context);
+    GetBuiltInType_void(clang::ASTContext *ast);
     
     lldb::clang_type_t
     GetBuiltInType_void()
@@ -146,7 +167,7 @@
     GetVoidPtrType(bool is_const);
     
     static lldb::clang_type_t
-    GetVoidPtrType(clang::ASTContext *ast_context, bool is_const);
+    GetVoidPtrType(clang::ASTContext *ast, bool is_const);
     
     static lldb::clang_type_t
     CopyType(clang::ASTContext *dest_context, 
@@ -159,7 +180,7 @@
               clang::Decl *source_decl);
 
     static bool
-    AreTypesSame(clang::ASTContext *ast_context,
+    AreTypesSame(clang::ASTContext *ast,
                  lldb::clang_type_t type1,
                  lldb::clang_type_t type2);
     
@@ -170,6 +191,13 @@
         return ClangASTContext::AreTypesSame(getASTContext(), type1, type2);
     }
     
+    
+    lldb::clang_type_t
+    GetTypeForDecl (clang::TagDecl *decl);
+    
+    lldb::clang_type_t
+    GetTypeForDecl (clang::ObjCInterfaceDecl *objc_decl);
+
     //------------------------------------------------------------------
     // CVR modifiers
     //------------------------------------------------------------------
@@ -194,7 +222,7 @@
                       lldb::LanguageType language);
 
     static bool
-    AddFieldToRecordType (clang::ASTContext *ast_context,
+    AddFieldToRecordType (clang::ASTContext *ast,
                           lldb::clang_type_t record_qual_type,
                           const char *name,
                           lldb::clang_type_t field_type,
@@ -217,7 +245,7 @@
     }
     
     static clang::CXXMethodDecl *
-    AddMethodToCXXRecordType (clang::ASTContext *ast_context,
+    AddMethodToCXXRecordType (clang::ASTContext *ast,
                               lldb::clang_type_t record_opaque_type,
                               const char *name,
                               lldb::clang_type_t method_type,
@@ -254,7 +282,7 @@
                      uint32_t& bitfield_bit_size);
 
     static bool
-    FieldIsBitfield (clang::ASTContext *ast_context,
+    FieldIsBitfield (clang::ASTContext *ast,
                      clang::FieldDecl* field,
                      uint32_t& bitfield_bit_size);
 
@@ -274,7 +302,7 @@
                      bool isInternal);
     
     static bool
-    AddObjCClassIVar (clang::ASTContext *ast_context,
+    AddObjCClassIVar (clang::ASTContext *ast,
                       lldb::clang_type_t class_opaque_type, 
                       const char *name, 
                       lldb::clang_type_t ivar_opaque_type, 
@@ -312,7 +340,7 @@
 
 
     static clang::ObjCMethodDecl *
-    AddMethodToObjCObjectType (clang::ASTContext *ast_context,
+    AddMethodToObjCObjectType (clang::ASTContext *ast,
                                lldb::clang_type_t class_opaque_type, 
                                const char *name,  // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]")
                                lldb::clang_type_t method_opaque_type,
@@ -331,6 +359,8 @@
                                           access);
     }
 
+    static bool
+    SetHasExternalStorage (lldb::clang_type_t clang_type, bool has_extern);
 
     //------------------------------------------------------------------
     // Aggregate Types
@@ -341,11 +371,12 @@
     // Returns a mask containing bits from the ClangASTContext::eTypeXXX enumerations
     static uint32_t
     GetTypeInfo (lldb::clang_type_t clang_type, 
-                     clang::ASTContext *ast_context,                // The AST for clang_type (can be NULL)
+                     clang::ASTContext *ast,                // The AST for clang_type (can be NULL)
                      lldb::clang_type_t *pointee_or_element_type);  // (can be NULL)
 
     static uint32_t
-    GetNumChildren (lldb::clang_type_t clang_type,
+    GetNumChildren (clang::ASTContext *ast,
+                    lldb::clang_type_t clang_type,
                     bool omit_empty_base_classes);
 
     static uint32_t
@@ -365,7 +396,7 @@
                               bool &child_is_base_class);
     
     static lldb::clang_type_t
-    GetChildClangTypeAtIndex (clang::ASTContext *ast_context,
+    GetChildClangTypeAtIndex (clang::ASTContext *ast,
                               const char *parent_name,
                               lldb::clang_type_t  parent_clang_type,
                               uint32_t idx,
@@ -381,7 +412,7 @@
     // Lookup a child given a name. This function will match base class names
     // and member member names in "clang_type" only, not descendants.
     static uint32_t
-    GetIndexOfChildWithName (clang::ASTContext *ast_context,
+    GetIndexOfChildWithName (clang::ASTContext *ast,
                              lldb::clang_type_t clang_type,
                              const char *name,
                              bool omit_empty_base_classes);
@@ -392,7 +423,7 @@
     // TODO: Return all matches for a given name by returning a vector<vector<uint32_t>>
     // so we catch all names that match a given child name, not just the first.
     static size_t
-    GetIndexOfChildMemberWithName (clang::ASTContext *ast_context,
+    GetIndexOfChildMemberWithName (clang::ASTContext *ast,
                                    lldb::clang_type_t clang_type,
                                    const char *name,
                                    bool omit_empty_base_classes,
@@ -452,7 +483,7 @@
                                bool is_inline);
     
     static lldb::clang_type_t
-    CreateFunctionType (clang::ASTContext *ast_context,
+    CreateFunctionType (clang::ASTContext *ast,
                         lldb::clang_type_t result_type,
                         lldb::clang_type_t *args,
                         unsigned num_args,
@@ -611,7 +642,7 @@
     GetArraySize (lldb::clang_type_t clang_type);
 
     //static bool
-    //ConvertFloatValueToString (clang::ASTContext *ast_context, 
+    //ConvertFloatValueToString (clang::ASTContext *ast, 
     //                           lldb::clang_type_t clang_type, 
     //                           const uint8_t* bytes, 
     //                           size_t byte_size, 
@@ -619,7 +650,7 @@
     //                           std::string &float_str);
     
     static size_t
-    ConvertStringToFloatValue (clang::ASTContext *ast_context, 
+    ConvertStringToFloatValue (clang::ASTContext *ast, 
                                lldb::clang_type_t clang_type, 
                                const char *s, 
                                uint8_t *dst, 
@@ -635,7 +666,7 @@
     // Classes that inherit from ClangASTContext can see and modify these
     //------------------------------------------------------------------
     std::string                             m_target_triple;
-    std::auto_ptr<clang::ASTContext>        m_ast_context_ap;
+    std::auto_ptr<clang::ASTContext>        m_ast_ap;
     std::auto_ptr<clang::LangOptions>       m_language_options_ap;
     std::auto_ptr<clang::FileManager>       m_file_manager_ap;
     std::auto_ptr<clang::FileSystemOptions> m_file_system_options_ap;
@@ -647,7 +678,9 @@
     std::auto_ptr<clang::IdentifierTable>   m_identifier_table_ap;
     std::auto_ptr<clang::SelectorTable>     m_selector_table_ap;
     std::auto_ptr<clang::Builtin::Context>  m_builtins_ap;
-
+    CompleteTagDeclCallback                 m_callback_tag_decl;
+    CompleteObjCInterfaceDeclCallback       m_callback_objc_decl;
+    void *                                  m_callback_baton;
 private:
     //------------------------------------------------------------------
     // For ClangASTContext only

Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Sun Jan 16 21:46:26 2011
@@ -56,7 +56,47 @@
     {
     }
 
+    //------------------------------------------------------------------
+    /// Get a mask of what this symbol file supports for the object file
+    /// that it was constructed with.
+    ///
+    /// Each symbol file gets to respond with a mask of abilities that
+    /// it supports for each object file. This happens when we are
+    /// trying to figure out which symbol file plug-in will get used
+    /// for a given object file. The plug-in that resoonds with the 
+    /// best mix of "SymbolFile::Abilities" bits set, will get chosen to
+    /// be the symbol file parser. This allows each plug-in to check for
+    /// sections that contain data a symbol file plug-in would need. For
+    /// example the DWARF plug-in requires DWARF sections in a file that
+    /// contain debug information. If the DWARF plug-in doesn't find
+    /// these sections, it won't respond with many ability bits set, and
+    /// we will probably fall back to the symbol table SymbolFile plug-in
+    /// which uses any information in the symbol table. Also, plug-ins 
+    /// might check for some specific symbols in a symbol table in the
+    /// case where the symbol table contains debug information (STABS
+    /// and COFF). Not a lot of work should happen in these functions
+    /// as the plug-in might not get selected due to another plug-in
+    /// having more abilities. Any initialization work should be saved
+    /// for "void SymbolFile::InitializeObject()" which will get called
+    /// on the SymbolFile object with the best set of abilities.
+    ///
+    /// @return
+    ///     A uint32_t mask containing bits from the SymbolFile::Abilities
+    ///     enumeration. Any bits that are set represent an ability that
+    ///     this symbol plug-in can parse from the object file.
+    ///------------------------------------------------------------------
     virtual uint32_t        GetAbilities () = 0;
+    
+    //------------------------------------------------------------------
+    /// Initialize the SymbolFile object.
+    ///
+    /// The SymbolFile object with the best set of abilities (detected
+    /// in "uint32_t SymbolFile::GetAbilities()) will have this function
+    /// called if it is chosen to parse an object file. More complete
+    /// initialization can happen in this function which will get called
+    /// prior to any other functions in the SymbolFile protocol.
+    //------------------------------------------------------------------    
+    virtual void            InitializeObject() {}
 
     //------------------------------------------------------------------
     // Compile Unit function calls
@@ -83,6 +123,8 @@
     virtual uint32_t        FindTypes (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) = 0;
 //  virtual uint32_t        FindTypes (const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, TypeList& types) = 0;
     virtual TypeList *      GetTypeList ();
+    virtual ClangASTContext &
+                            GetClangASTContext ();
     virtual ClangNamespaceDecl
                             FindNamespace (const SymbolContext& sc, 
                                            const ConstString &name) = 0;
@@ -90,7 +132,7 @@
     ObjectFile*             GetObjectFile() { return m_obj_file; }
     const ObjectFile*       GetObjectFile() const { return m_obj_file; }
 protected:
-    ObjectFile*         m_obj_file; // The object file that symbols can be extracted from.
+    ObjectFile*             m_obj_file; // The object file that symbols can be extracted from.
 
 private:
     DISALLOW_COPY_AND_ASSIGN (SymbolFile);

Modified: lldb/trunk/include/lldb/Symbol/TaggedASTType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TaggedASTType.h?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/TaggedASTType.h (original)
+++ lldb/trunk/include/lldb/Symbol/TaggedASTType.h Sun Jan 16 21:46:26 2011
@@ -20,7 +20,7 @@
 template <unsigned int C> class TaggedASTType : public ClangASTType
 {
 public:
-    TaggedASTType (void *type, clang::ASTContext *ast_context) :
+    TaggedASTType (lldb::clang_type_t type, clang::ASTContext *ast_context) :
         ClangASTType(type, ast_context) { }
     
     TaggedASTType (const TaggedASTType<C> &tw) :

Modified: lldb/trunk/include/lldb/Symbol/Type.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Type.h (original)
+++ lldb/trunk/include/lldb/Symbol/Type.h Sun Jan 16 21:46:26 2011
@@ -226,6 +226,21 @@
     uint32_t
     GetEncodingMask ();
 
+    void *
+    CreateClangPointerType (Type *type);
+
+    void *
+    CreateClangTypedefType (Type *typedef_type, Type *base_type);
+
+    // For C++98 references (&)
+    void *
+    CreateClangLValueReferenceType (Type *type);
+
+    // For C++0x references (&&)
+    void *
+    CreateClangRValueReferenceType (Type *type);
+
+
 protected:
     ConstString m_name;
     SymbolFile *m_symbol_file;

Modified: lldb/trunk/include/lldb/Symbol/TypeList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeList.h?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/TypeList.h (original)
+++ lldb/trunk/include/lldb/Symbol/TypeList.h Sun Jan 16 21:46:26 2011
@@ -11,7 +11,6 @@
 #define liblldb_TypeList_h_
 
 #include "lldb/lldb-private.h"
-#include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/Type.h"
 #include <map>
 
@@ -23,7 +22,7 @@
     //------------------------------------------------------------------
     // Constructors and Destructors
     //------------------------------------------------------------------
-    TypeList(const char *target_triple = NULL);
+    TypeList();
 
     virtual
     ~TypeList();
@@ -52,31 +51,10 @@
     lldb::TypeSP
     GetTypeAtIndex(uint32_t idx);
 
-    //------------------------------------------------------------------
-    // Classes that inherit from TypeList can see and modify these
-    //------------------------------------------------------------------
-    ClangASTContext &
-    GetClangASTContext ();
-
-    void *
-    CreateClangPointerType (Type *type);
-
-    void *
-    CreateClangTypedefType (Type *typedef_type, Type *base_type);
-
-    // For C++98 references (&)
-    void *
-    CreateClangLValueReferenceType (Type *type);
-
-    // For C++0x references (&&)
-    void *
-    CreateClangRValueReferenceType (Type *type);
-
 private:
     typedef std::multimap<lldb::user_id_t, lldb::TypeSP> collection;
     typedef collection::iterator iterator;
     typedef collection::const_iterator const_iterator;
-    ClangASTContext m_ast; ///< The type abtract syntax tree.
 
     collection m_types;
 

Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Sun Jan 16 21:46:26 2011
@@ -48,6 +48,8 @@
 class   ClangExpressionVariable;
 class   ClangExpressionVariableList;
 class   ClangExpressionVariableList;
+class   ClangExpressionVariables;
+class   ClangPersistentVariables;
 class   CommandInterpreter;
 class   CommandObject;
 class   CommandReturnObject;
@@ -90,6 +92,7 @@
 class   Module;
 class   ModuleList;
 class   Mutex;
+class   NameSearchContext;
 class   ObjCLanguageRuntime;
 class   ObjectContainer;
 class   ObjectFile;

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sun Jan 16 21:46:26 2011
@@ -305,6 +305,8 @@
 		26DE20611161902700A093E2 /* SBBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DE20601161902600A093E2 /* SBBlock.cpp */; };
 		26DE20631161904200A093E2 /* SBLineEntry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DE20621161904200A093E2 /* SBLineEntry.cpp */; };
 		26DE20651161904E00A093E2 /* SBSymbol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DE20641161904E00A093E2 /* SBSymbol.cpp */; };
+		26E6902F129C6BD500DDECD9 /* ClangExternalASTSourceCallbacks.h in Headers */ = {isa = PBXBuildFile; fileRef = 26E6902E129C6BD500DDECD9 /* ClangExternalASTSourceCallbacks.h */; };
+		26E69031129C6BEF00DDECD9 /* ClangExternalASTSourceCallbacks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E69030129C6BEF00DDECD9 /* ClangExternalASTSourceCallbacks.cpp */; };
 		26F5C27710F3D9E4009D5894 /* Driver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F5C27310F3D9E4009D5894 /* Driver.cpp */; };
 		26F5C27810F3D9E4009D5894 /* IOChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F5C27510F3D9E4009D5894 /* IOChannel.cpp */; };
 		26F5C32510F3DF23009D5894 /* libpython.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32410F3DF23009D5894 /* libpython.dylib */; };
@@ -896,6 +898,8 @@
 		26E3EEE411A9901300FBADB6 /* UnwindMacOSXFrameBackchain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnwindMacOSXFrameBackchain.h; path = Utility/UnwindMacOSXFrameBackchain.h; sourceTree = "<group>"; };
 		26E3EEF711A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextMacOSXFrameBackchain.cpp; path = Utility/RegisterContextMacOSXFrameBackchain.cpp; sourceTree = "<group>"; };
 		26E3EEF811A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextMacOSXFrameBackchain.h; path = Utility/RegisterContextMacOSXFrameBackchain.h; sourceTree = "<group>"; };
+		26E6902E129C6BD500DDECD9 /* ClangExternalASTSourceCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangExternalASTSourceCallbacks.h; path = include/lldb/Symbol/ClangExternalASTSourceCallbacks.h; sourceTree = "<group>"; };
+		26E69030129C6BEF00DDECD9 /* ClangExternalASTSourceCallbacks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangExternalASTSourceCallbacks.cpp; path = source/Symbol/ClangExternalASTSourceCallbacks.cpp; sourceTree = "<group>"; };
 		26F5C26A10F3D9A4009D5894 /* lldb */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = lldb; sourceTree = BUILT_PRODUCTS_DIR; };
 		26F5C27210F3D9E4009D5894 /* lldb-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "lldb-Info.plist"; path = "tools/driver/lldb-Info.plist"; sourceTree = "<group>"; };
 		26F5C27310F3D9E4009D5894 /* Driver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Driver.cpp; path = tools/driver/Driver.cpp; sourceTree = "<group>"; };
@@ -1750,6 +1754,8 @@
 				26BC7F1410F1B8EC00F91463 /* ClangASTContext.cpp */,
 				49E45FA911F660DC008F7B28 /* ClangASTType.h */,
 				49E45FAD11F660FE008F7B28 /* ClangASTType.cpp */,
+				26E6902E129C6BD500DDECD9 /* ClangExternalASTSourceCallbacks.h */,
+				26E69030129C6BEF00DDECD9 /* ClangExternalASTSourceCallbacks.cpp */,
 				266A42D7128E40040090CF7C /* ClangNamespaceDecl.h */,
 				266A42D5128E3FFB0090CF7C /* ClangNamespaceDecl.cpp */,
 				26BC7C5710F1B6E900F91463 /* CompileUnit.h */,
@@ -2291,6 +2297,7 @@
 				4C61978F12823D4300FAFFCC /* AppleObjCRuntimeV1.h in Headers */,
 				4CC2A14D128C7409001531C4 /* ThreadPlanTracer.h in Headers */,
 				266A42D8128E40040090CF7C /* ClangNamespaceDecl.h in Headers */,
+				26E6902F129C6BD500DDECD9 /* ClangExternalASTSourceCallbacks.h in Headers */,
 				4C7CF7E41295E10E00B4FBB5 /* ThreadPlanCallUserExpression.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -2790,6 +2797,7 @@
 				4C61978E12823D4300FAFFCC /* AppleObjCRuntimeV1.cpp in Sources */,
 				4CC2A149128C73ED001531C4 /* ThreadPlanTracer.cpp in Sources */,
 				266A42D6128E3FFB0090CF7C /* ClangNamespaceDecl.cpp in Sources */,
+				26E69031129C6BEF00DDECD9 /* ClangExternalASTSourceCallbacks.cpp in Sources */,
 				4C7CF7E61295E12B00B4FBB5 /* ThreadPlanCallUserExpression.cpp in Sources */,
 				B296983712C2FB98002D92C3 /* CommandObjectVersion.cpp in Sources */,
 			);
@@ -2939,6 +2947,11 @@
 				GCC_ENABLE_OBJC_GC = supported;
 				GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
 				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					__STDC_CONSTANT_MACROS,
+					__STDC_LIMIT_MACROS,
+					LLDB_CONFIGURATION_DEBUG,
+				);
 				HEADER_SEARCH_PATHS = "";
 				INFOPLIST_FILE = "resources/LLDB-Info.plist";
 				INSTALL_PATH = /Developer/Library/PrivateFrameworks;
@@ -2948,7 +2961,7 @@
 					"$(LLVM_BUILD_DIR)",
 				);
 				LLVM_BUILD_DIR = "$(SRCROOT)/llvm";
-				LLVM_CONFIGURATION = "Debug+Asserts";
+				LLVM_CONFIGURATION = Release;
 				OTHER_CFLAGS = (
 					"-DFOR_DYLD=0",
 					"-DSUPPORT_REMOTE_UNWINDING",
@@ -2991,6 +3004,11 @@
 				FRAMEWORK_VERSION = A;
 				GCC_ENABLE_OBJC_GC = supported;
 				GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					__STDC_CONSTANT_MACROS,
+					__STDC_LIMIT_MACROS,
+					LLDB_CONFIGURATION_RELEASE,
+				);
 				HEADER_SEARCH_PATHS = "";
 				INFOPLIST_FILE = "resources/LLDB-Info.plist";
 				INSTALL_PATH = /Developer/Library/PrivateFrameworks;
@@ -3100,6 +3118,11 @@
 				FRAMEWORK_VERSION = A;
 				GCC_ENABLE_OBJC_GC = supported;
 				GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					__STDC_CONSTANT_MACROS,
+					__STDC_LIMIT_MACROS,
+					LLDB_CONFIGURATION_BUILD_AND_INTEGRATION,
+				);
 				HEADER_SEARCH_PATHS = "";
 				INFOPLIST_FILE = "resources/LLDB-Info.plist";
 				INSTALL_PATH = /Developer/Library/PrivateFrameworks;

Modified: lldb/trunk/source/API/SBType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBType.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/API/SBType.cpp (original)
+++ lldb/trunk/source/API/SBType.cpp Sun Jan 16 21:46:26 2011
@@ -96,7 +96,9 @@
 SBType::GetNumberChildren (bool omit_empty_base_classes)
 {
     if (IsValid ())
-        return ClangASTContext::GetNumChildren(m_type, omit_empty_base_classes);
+        return ClangASTContext::GetNumChildren (static_cast<clang::ASTContext *>(m_ast),
+                                                m_type, 
+                                                omit_empty_base_classes);
     return 0;
 }
 

Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Sun Jan 16 21:46:26 2011
@@ -457,7 +457,18 @@
 {
     if (m_opaque_sp)
     {
-        m_opaque_sp->GetExpressionPath (description.ref());
+        m_opaque_sp->GetExpressionPath (description.ref(), false);
+        return true;
+    }
+    return false;
+}
+
+bool
+SBValue::GetExpressionPath (SBStream &description, bool qualify_cxx_base_classes)
+{
+    if (m_opaque_sp)
+    {
+        m_opaque_sp->GetExpressionPath (description.ref(), qualify_cxx_base_classes);
         return true;
     }
     return false;

Modified: lldb/trunk/source/Commands/CommandObjectArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectArgs.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectArgs.cpp Sun Jan 16 21:46:26 2011
@@ -156,15 +156,7 @@
         return false;
     }
     
-    TypeList *thread_type_list = thread_module->GetTypeList ();
-    if (!thread_type_list)
-    {
-        result.AppendError ("The module has no type list.");
-        result.SetStatus (eReturnStatusFailed);
-        return false;
-    }
-    
-    ClangASTContext &ast_context = thread_type_list->GetClangASTContext();
+    ClangASTContext &ast_context = thread_module->GetClangASTContext();
     
     ValueList value_list;
     

Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Sun Jan 16 21:46:26 2011
@@ -29,9 +29,11 @@
     m_object_name (),
     m_objfile_ap (),
     m_symfile_ap (),
+    m_ast (),
     m_did_load_objfile (false),
     m_did_load_symbol_vendor (false),
     m_did_parse_uuid (false),
+    m_did_init_ast (false),
     m_is_dynamic_loader_module (false)
 {
     if (object_name)
@@ -60,6 +62,13 @@
                      m_object_name.IsEmpty() ? "" : "(",
                      m_object_name.IsEmpty() ? "" : m_object_name.AsCString(""),
                      m_object_name.IsEmpty() ? "" : ")");
+    // Release any auto pointers before we start tearing down our member 
+    // variables since the object file and symbol files might need to make
+    // function calls back into this module object. The ordering is important
+    // here because symbol files can require the module object file. So we tear
+    // down the symbol file first, then the object file.
+    m_symfile_ap.reset();
+    m_objfile_ap.reset();
 }
 
 
@@ -86,6 +95,23 @@
     return m_uuid;
 }
 
+ClangASTContext &
+Module::GetClangASTContext ()
+{
+    Mutex::Locker locker (m_mutex);
+    if (m_did_init_ast == false)
+    {
+        ObjectFile * objfile = GetObjectFile();
+        ConstString target_triple;
+        if (objfile && objfile->GetTargetTriple(target_triple))
+        {
+            m_did_init_ast = true;
+            m_ast.SetTargetTriple (target_triple.AsCString());
+        }
+    }
+    return m_ast;
+}
+
 void
 Module::ParseAllDebugSymbols()
 {

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Sun Jan 16 21:46:26 2011
@@ -944,11 +944,11 @@
 
 
 void
-ValueObject::GetExpressionPath (Stream &s)
+ValueObject::GetExpressionPath (Stream &s, bool qualify_cxx_base_classes)
 {
     if (m_parent)
     {
-        m_parent->GetExpressionPath (s);
+        m_parent->GetExpressionPath (s, qualify_cxx_base_classes);
         clang_type_t parent_clang_type = m_parent->GetClangType();
         if (parent_clang_type)
         {
@@ -967,11 +967,14 @@
     
     if (IsBaseClass())
     {
-        clang_type_t clang_type = GetClangType();
-        std::string cxx_class_name;
-        if (ClangASTContext::GetCXXClassName (clang_type, cxx_class_name))
+        if (qualify_cxx_base_classes)
         {
-            s << cxx_class_name.c_str() << "::";
+            clang_type_t clang_type = GetClangType();
+            std::string cxx_class_name;
+            if (ClangASTContext::GetCXXClassName (clang_type, cxx_class_name))
+            {
+                s << cxx_class_name.c_str() << "::";
+            }
         }
     }
     else
@@ -1026,7 +1029,9 @@
 
             if (flat_output)
             {
-                valobj->GetExpressionPath(s);
+                // If we are showing types, also qualify the C++ base classes 
+                const bool qualify_cxx_base_classes = show_types;
+                valobj->GetExpressionPath(s, qualify_cxx_base_classes);
                 s.PutCString(" =");
             }
             else
@@ -1270,7 +1275,7 @@
     else
     {
         StreamString strm;
-        GetExpressionPath(strm);
+        GetExpressionPath(strm, true);
 
         if (is_pointer_type)
             error.SetErrorStringWithFormat("dereference failed: (%s) %s", GetTypeName().AsCString("<invalid type>"), strm.GetString().c_str());
@@ -1297,7 +1302,7 @@
         case eAddressTypeInvalid:
             {
                 StreamString expr_path_strm;
-                GetExpressionPath(expr_path_strm);
+                GetExpressionPath(expr_path_strm, true);
                 error.SetErrorStringWithFormat("'%s' is not in memory", expr_path_strm.GetString().c_str());
             }
             break;

Modified: lldb/trunk/source/Core/ValueObjectChild.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectChild.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectChild.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectChild.cpp Sun Jan 16 21:46:26 2011
@@ -61,7 +61,7 @@
 uint32_t
 ValueObjectChild::CalculateNumChildren()
 {
-    return ClangASTContext::GetNumChildren (m_clang_type, true);
+    return ClangASTContext::GetNumChildren (GetClangAST (), m_clang_type, true);
 }
 
 ConstString

Modified: lldb/trunk/source/Core/ValueObjectConstResult.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectConstResult.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectConstResult.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectConstResult.cpp Sun Jan 16 21:46:26 2011
@@ -139,7 +139,7 @@
 {
 }
 
-void *
+lldb::clang_type_t
 ValueObjectConstResult::GetClangType()
 {
     return m_value.GetClangType();
@@ -171,7 +171,7 @@
 uint32_t
 ValueObjectConstResult::CalculateNumChildren()
 {
-    return ClangASTContext::GetNumChildren (GetClangType(), true);
+    return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true);
 }
 
 clang::ASTContext *

Modified: lldb/trunk/source/Core/ValueObjectRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectRegister.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectRegister.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectRegister.cpp Sun Jan 16 21:46:26 2011
@@ -42,7 +42,7 @@
 {
 }
 
-void *
+lldb::clang_type_t
 ValueObjectRegisterContext::GetClangType ()
 {
     return NULL;
@@ -119,7 +119,7 @@
 {
 }
 
-void *
+lldb::clang_type_t
 ValueObjectRegisterSet::GetClangType ()
 {
     return NULL;
@@ -227,7 +227,7 @@
 {
 }
 
-void *
+lldb::clang_type_t
 ValueObjectRegister::GetClangType ()
 {
     if (m_clang_type == NULL && m_reg_info)
@@ -238,9 +238,7 @@
             Module *exe_module = process->GetTarget().GetExecutableModule ().get();
             if (exe_module)
             {
-                TypeList *type_list = exe_module->GetTypeList();
-                if (type_list)
-                    m_clang_type = type_list->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize (m_reg_info->encoding, m_reg_info->byte_size * 8);
+                m_clang_type = exe_module->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize (m_reg_info->encoding, m_reg_info->byte_size * 8);
             }
         }
     }
@@ -269,11 +267,7 @@
     {
         Module *exe_module = process->GetTarget().GetExecutableModule ().get();
         if (exe_module)
-        {
-            TypeList *type_list = exe_module->GetTypeList();
-            if (type_list)
-                return type_list->GetClangASTContext().getASTContext();
-        }
+            return exe_module->GetClangASTContext().getASTContext();
     }
     return NULL;
 }

Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectVariable.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectVariable.cpp Sun Jan 16 21:46:26 2011
@@ -45,12 +45,12 @@
 {
 }
 
-void *
+lldb::clang_type_t
 ValueObjectVariable::GetClangType ()
 {
     Type *var_type = m_variable_sp->GetType();
     if (var_type)
-        return var_type->GetClangType();
+        return var_type->GetClangForwardType();
     return NULL;
 }
 

Modified: lldb/trunk/source/Expression/ClangASTSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangASTSource.cpp (original)
+++ lldb/trunk/source/Expression/ClangASTSource.cpp Sun Jan 16 21:46:26 2011
@@ -17,34 +17,34 @@
 using namespace clang;
 using namespace lldb_private;
 
-ClangASTSource::~ClangASTSource() {}
+ClangASTSource::~ClangASTSource() 
+{
+}
 
-void ClangASTSource::StartTranslationUnit(ASTConsumer *Consumer) {
+void
+ClangASTSource::StartTranslationUnit(ASTConsumer *Consumer) 
+{
     // Tell Sema to ask us when looking into the translation unit's decl.
     m_ast_context.getTranslationUnitDecl()->setHasExternalVisibleStorage();
     m_ast_context.getTranslationUnitDecl()->setHasExternalLexicalStorage();
 }
 
-// These are only required for AST source that want to lazily load
-// the declarations (or parts thereof) that they return.
-Decl *ClangASTSource::GetExternalDecl(uint32_t) { return 0; }
-Stmt *ClangASTSource::GetExternalDeclStmt(uint64_t) { return 0; }
-
-// These are also optional, although it might help with ObjC
-// debugging if we have respectable signatures.  But a more
-// efficient interface (that didn't require scanning all files
-// for method signatures!) might help.
-Selector ClangASTSource::GetExternalSelector(uint32_t) { return Selector(); }
-uint32_t ClangASTSource::GetNumExternalSelectors() { return 0; }
-CXXBaseSpecifier *ClangASTSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) { return NULL; }
-
 // The core lookup interface.
-DeclContext::lookup_result ClangASTSource::FindExternalVisibleDeclsByName
+DeclContext::lookup_result 
+ClangASTSource::FindExternalVisibleDeclsByName
 (
     const DeclContext *decl_ctx, 
     DeclarationName clang_decl_name
 ) 
 {
+    if (m_decl_map.GetImportInProgress())
+        return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+        
+    std::string decl_name (clang_decl_name.getAsString());
+
+//    if (m_decl_map.DoingASTImport ())
+//      return DeclContext::lookup_result();
+//        
     switch (clang_decl_name.getNameKind()) {
     // Normal identifiers.
     case DeclarationName::Identifier:
@@ -75,7 +75,6 @@
       return DeclContext::lookup_result();
     }
 
-    std::string decl_name (clang_decl_name.getAsString());
 
     if (!m_decl_map.GetLookupsEnabled())
     {
@@ -112,25 +111,47 @@
     return result;
 }
 
-void ClangASTSource::MaterializeVisibleDecls(const DeclContext *DC)
+void
+ClangASTSource::CompleteType (TagDecl *tag_decl)
+{
+    puts(__PRETTY_FUNCTION__);
+}
+
+void
+ClangASTSource::CompleteType (ObjCInterfaceDecl *objc_decl)
+{
+    puts(__PRETTY_FUNCTION__);
+}
+
+void 
+ClangASTSource::MaterializeVisibleDecls(const DeclContext *DC)
 {
     return;
 }
 
 // This is used to support iterating through an entire lexical context,
 // which isn't something the debugger should ever need to do.
-bool ClangASTSource::FindExternalLexicalDecls(const DeclContext *DC, 
-                                              bool (*isKindWeWant)(Decl::Kind),
-                                              llvm::SmallVectorImpl<Decl*> &Decls) {
+bool
+ClangASTSource::FindExternalLexicalDecls
+(
+    const DeclContext *DC, 
+    bool (*isKindWeWant)(Decl::Kind),
+    llvm::SmallVectorImpl<Decl*> &Decls
+)
+{
 	// true is for error, that's good enough for me
 	return true;
 }
 
-clang::ASTContext *NameSearchContext::GetASTContext() {
+clang::ASTContext *
+NameSearchContext::GetASTContext() 
+{
     return &m_ast_source.m_ast_context;
 }
 
-clang::NamedDecl *NameSearchContext::AddVarDecl(void *type) {
+clang::NamedDecl *
+NameSearchContext::AddVarDecl(void *type) 
+{
     IdentifierInfo *ii = m_decl_name.getAsIdentifierInfo();
     
     assert (type && "Type for variable must be non-NULL!");
@@ -148,7 +169,9 @@
     return Decl;
 }
 
-clang::NamedDecl *NameSearchContext::AddFunDecl (void *type) {
+clang::NamedDecl *
+NameSearchContext::AddFunDecl (void *type) 
+{
     clang::FunctionDecl *func_decl = FunctionDecl::Create (m_ast_source.m_ast_context,
                                                            const_cast<DeclContext*>(m_decl_context),
                                                            SourceLocation(),
@@ -199,7 +222,8 @@
     return func_decl;
 }
 
-clang::NamedDecl *NameSearchContext::AddGenericFunDecl()
+clang::NamedDecl *
+NameSearchContext::AddGenericFunDecl()
 {
     QualType generic_function_type(m_ast_source.m_ast_context.getFunctionType (m_ast_source.m_ast_context.getSizeType(),   // result
                                                                                NULL,                              // argument types
@@ -215,7 +239,8 @@
     return AddFunDecl(generic_function_type.getAsOpaquePtr());
 }
 
-clang::NamedDecl *NameSearchContext::AddTypeDecl(void *type)
+clang::NamedDecl *
+NameSearchContext::AddTypeDecl(void *type)
 {
     QualType qual_type = QualType::getFromOpaquePtr(type);
 

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Sun Jan 16 21:46:26 2011
@@ -1711,8 +1711,8 @@
             log->PutCString (strm.GetData());
         }
 
-        TypeFromUser user_type(type_sp->GetClangType(),
-                                   type_sp->GetClangAST());
+        TypeFromUser user_type (type_sp->GetClangType(),
+                                type_sp->GetClangAST());
             
         AddOneType(context, user_type, false);
     }
@@ -1748,18 +1748,9 @@
         return NULL;
     }
     
-    TypeList *type_list = var_type->GetTypeList();
+    clang::ASTContext *ast = var_type->GetClangASTContext().getASTContext();
     
-    if (!type_list)
-    {
-        if (log)
-            log->PutCString("Skipped a definition because the type has no associated type list");
-        return NULL;
-    }
-    
-    clang::ASTContext *exe_ast_ctx = type_list->GetClangASTContext().getASTContext();
-    
-    if (!exe_ast_ctx)
+    if (!ast)
     {
         if (log)
             log->PutCString("There is no AST context for the current execution context");
@@ -1780,20 +1771,18 @@
     }
     Error err;
     
-    if (!var_location_expr.Evaluate(&exe_ctx, exe_ast_ctx, NULL, loclist_base_load_addr, NULL, *var_location.get(), &err))
+    if (!var_location_expr.Evaluate(&exe_ctx, ast, NULL, loclist_base_load_addr, NULL, *var_location.get(), &err))
     {
         if (log)
             log->Printf("Error evaluating location: %s", err.AsCString());
         return NULL;
     }
-    
-    clang::ASTContext *var_ast_context = type_list->GetClangASTContext().getASTContext();
-    
+        
     void *type_to_use;
     
     if (parser_ast_context)
     {
-        type_to_use = GuardedCopyType(parser_ast_context, var_ast_context, var_opaque_type);
+        type_to_use = GuardedCopyType(parser_ast_context, ast, var_opaque_type);
         
         if (!type_to_use)
         {
@@ -1834,14 +1823,13 @@
     }
     
     if (user_type)
-        *user_type = TypeFromUser(var_opaque_type, var_ast_context);
+        *user_type = TypeFromUser(var_opaque_type, ast);
     
     return var_location.release();
 }
 
 void
-ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
-                                       Variable* var)
+ClangExpressionDeclMap::AddOneVariable (NameSearchContext &context, Variable* var)
 {
     assert (m_parser_vars.get());
     
@@ -1965,7 +1953,6 @@
 {
     lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
-    
     clang::Decl *copied_decl = ClangASTContext::CopyDecl (context.GetASTContext(),
                                                           namespace_decl.GetASTContext(),
                                                           namespace_decl.GetNamespaceDecl());
@@ -2012,8 +1999,7 @@
         
         fun_address = &fun->GetAddressRange().GetBaseAddress();
         
-        TypeList *type_list = fun_type->GetTypeList();
-        fun_ast_context = type_list->GetClangASTContext().getASTContext();
+        fun_ast_context = fun_type->GetClangASTContext().getASTContext();
         void *copied_type = GuardedCopyType(context.GetASTContext(), fun_ast_context, fun_opaque_type);
         
         fun_decl = context.AddFunDecl(copied_type);

Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Sun Jan 16 21:46:26 2011
@@ -186,6 +186,7 @@
             break_regex_cmd_ap->AddRegexCommand("^[\"']?([-+]\\[.*\\])[\"']?[[:space:]]*$", "breakpoint set --name '%1'") &&
             break_regex_cmd_ap->AddRegexCommand("^$", "breakpoint list") &&
             break_regex_cmd_ap->AddRegexCommand("^(-.*)$", "breakpoint set %1") &&
+            break_regex_cmd_ap->AddRegexCommand("^(.*[^[:space:]])`(.*[^[:space:]])[[:space:]]*$", "breakpoint set --name '%2' --shlib '%1'") &&
             break_regex_cmd_ap->AddRegexCommand("^(.*[^[:space:]])[[:space:]]*$", "breakpoint set --name '%1'"))
         {
             CommandObjectSP break_regex_cmd_sp(break_regex_cmd_ap.release());

Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original)
+++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Sun Jan 16 21:46:26 2011
@@ -25,8 +25,7 @@
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Target.h"
 
-#include <memory>
-#include <string>
+#include <assert.h>
 
 using namespace lldb;
 using namespace lldb_private;
@@ -380,12 +379,14 @@
 }
 
 DisassemblerLLVM::DisassemblerLLVM(const ArchSpec &arch) :
-    Disassembler(arch)
+    Disassembler (arch),
+    m_disassembler (NULL)
 {
     char triple[256];
     if (TripleForArchSpec (arch, triple, sizeof(triple)))
     {
-        assert(!EDGetDisassembler(&m_disassembler, triple, SyntaxForArchSpec (arch)) && "No disassembler created!");
+        int err = EDGetDisassembler(&m_disassembler, triple, SyntaxForArchSpec (arch));
+        assert (err == 0);
     }
 }
 
@@ -402,6 +403,9 @@
     uint32_t num_instructions
 )
 {
+    if (m_disassembler == NULL)
+        return 0;
+
     size_t total_inst_byte_size = 0;
 
     m_instruction_list.Clear();

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Sun Jan 16 21:46:26 2011
@@ -574,12 +574,6 @@
 
         m_byte_order = m_gdb_comm.GetByteOrder();
 
-        Module * exe_module = GetTarget().GetExecutableModule().get();        
-        assert(exe_module);
-
-        ObjectFile *exe_objfile = exe_module->GetObjectFile();
-        assert(exe_objfile);
-
         StreamString strm;
 
         ArchSpec inferior_arch;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Sun Jan 16 21:46:26 2011
@@ -32,6 +32,7 @@
 #include "lldb/Core/Value.h"
 
 #include "lldb/Symbol/Block.h"
+#include "lldb/Symbol/ClangExternalASTSourceCallbacks.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/LineTable.h"
 #include "lldb/Symbol/ObjectFile.h"
@@ -118,13 +119,6 @@
     return new SymbolFileDWARF(obj_file);
 }
 
-
-ClangASTContext &
-SymbolFileDWARF::GetClangASTContext()
-{
-    return GetTypeList()->GetClangASTContext();
-}
-
 TypeList *          
 SymbolFileDWARF::GetTypeList ()
 {
@@ -183,13 +177,61 @@
     m_global_index(),
     m_type_index(),
     m_namespace_index(),
-    m_indexed(false),
+    m_indexed (false),
+    m_is_external_ast_source (false),
     m_ranges()
 {
 }
 
 SymbolFileDWARF::~SymbolFileDWARF()
 {
+    if (m_is_external_ast_source)
+        m_obj_file->GetModule()->GetClangASTContext().RemoveExternalSource ();
+}
+
+static const ConstString &
+GetDWARFMachOSegmentName ()
+{
+    static ConstString g_dwarf_section_name ("__DWARF");
+    return g_dwarf_section_name;
+}
+
+ClangASTContext &       
+SymbolFileDWARF::GetClangASTContext ()
+{
+    if (m_debug_map_symfile)
+        return m_debug_map_symfile->GetClangASTContext ();
+
+    ClangASTContext &ast = m_obj_file->GetModule()->GetClangASTContext();
+    if (!m_is_external_ast_source)
+    {
+        m_is_external_ast_source = true;
+        llvm::OwningPtr<clang::ExternalASTSource> ast_source_ap (
+            new ClangExternalASTSourceCallbacks (SymbolFileDWARF::CompleteTagDecl,
+                                                 SymbolFileDWARF::CompleteObjCInterfaceDecl,
+                                                 this));
+
+        ast.SetExternalSource (ast_source_ap);
+    }
+    return ast;
+}
+
+void
+SymbolFileDWARF::InitializeObject()
+{
+    // Install our external AST source callbacks so we can complete Clang types.
+    Module *module = m_obj_file->GetModule();
+    if (module)
+    {
+        const SectionList *section_list = m_obj_file->GetSectionList();
+
+        const Section* section = section_list->FindSectionByName(GetDWARFMachOSegmentName ()).get();
+
+        // Memory map the DWARF mach-o segment so we have everything mmap'ed
+        // to keep our heap memory usage down.
+        if (section)
+            section->MemoryMapSectionDataFromObjectFile(m_obj_file, m_dwarf_data);
+    }
 }
 
 bool
@@ -221,15 +263,10 @@
         uint64_t debug_ranges_file_size = 0;
         uint64_t debug_str_file_size = 0;
 
-        static ConstString g_dwarf_section_name ("__DWARF");
-
-        section = section_list->FindSectionByName(g_dwarf_section_name).get();
+        section = section_list->FindSectionByName(GetDWARFMachOSegmentName ()).get();
         
         if (section)
-        {
-            section->MemoryMapSectionDataFromObjectFile(m_obj_file, m_dwarf_data);
             section_list = &section->GetChildren ();
-        }
         
         section = section_list->FindSectionByType (eSectionTypeDWARFDebugInfo, true).get();
         if (section != NULL)
@@ -1079,6 +1116,7 @@
     size_t count = 0;
     const DWARFDebugInfoEntry *die;
     const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize());
+    uint32_t member_idx = 0;
 
     for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling())
     {
@@ -1155,6 +1193,17 @@
                     if (class_language == eLanguageTypeObjC ||
                         class_language == eLanguageTypeObjC_plus_plus)
                         accessibility = eAccessNone; 
+                    
+                    if (member_idx == 0 && !is_artificial && name && (strstr (name, "_vptr$") == name))
+                    {
+                        // Not all compilers will mark the vtable pointer
+                        // member as artificial (llvm-gcc). We can't have
+                        // the virtual members in our classes otherwise it
+                        // throws off all child offsets since we end up
+                        // having and extra pointer sized member in our 
+                        // class layouts.
+                        is_artificial = true;
+                    }
 
                     if (is_artificial == false)
                     {
@@ -1171,6 +1220,7 @@
                                                                    bit_size);
                     }
                 }
+                ++member_idx;
             }
             break;
 
@@ -1319,13 +1369,32 @@
     return NULL;
 }
 
+// This function is used when SymbolFileDWARFDebugMap owns a bunch of
+// SymbolFileDWARF objects to detect if this DWARF file is the one that
+// can resolve a clang_type.
+bool
+SymbolFileDWARF::HasForwardDeclForClangType (lldb::clang_type_t clang_type)
+{
+    clang_type_t clang_type_no_qualifiers = ClangASTType::RemoveFastQualifiers(clang_type);
+    const DWARFDebugInfoEntry* die = m_forward_decl_clang_type_to_die.lookup (clang_type_no_qualifiers);
+    return die != NULL;
+}
+
+
 lldb::clang_type_t
 SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_type)
 {
     // We have a struct/union/class/enum that needs to be fully resolved.
-    const DWARFDebugInfoEntry* die = m_forward_decl_clang_type_to_die.lookup (ClangASTType::RemoveFastQualifiers(clang_type));
+    clang_type_t clang_type_no_qualifiers = ClangASTType::RemoveFastQualifiers(clang_type);
+    const DWARFDebugInfoEntry* die = m_forward_decl_clang_type_to_die.lookup (clang_type_no_qualifiers);
     if (die == NULL)
     {
+//        if (m_debug_map_symfile)
+//        {
+//            Type *type = m_die_to_type[die];
+//            if (type && type->GetSymbolFile() != this)
+//                return type->GetClangType();
+//        }
         // We have already resolved this type...
         return clang_type;
     }
@@ -1333,7 +1402,7 @@
     // map in case anyone child members or other types require this type to get resolved.
     // The type will get resolved when all of the calls to SymbolFileDWARF::ResolveClangOpaqueTypeDefinition
     // are done.
-    m_forward_decl_clang_type_to_die.erase (ClangASTType::RemoveFastQualifiers(clang_type));
+    m_forward_decl_clang_type_to_die.erase (clang_type_no_qualifiers);
     
 
     DWARFDebugInfo* debug_info = DebugInfo();
@@ -2743,7 +2812,7 @@
                     if (namespace_name)
                     {
                         Declaration decl;   // TODO: fill in the decl object
-                        clang::NamespaceDecl *namespace_decl = GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, decl, GetClangDeclContextForDIE (curr_cu, die->GetParent()));
+                        clang::NamespaceDecl *namespace_decl = GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, decl, GetClangDeclContextForDIE (curr_cu, die));
                         if (namespace_decl)
                         {
                             //printf ("SymbolFileDWARF::GetClangDeclContextForDIE ( die = 0x%8.8x ) => 0x%8.8x\n", decl_die->GetOffset(), die->GetOffset());
@@ -2775,7 +2844,7 @@
         }
 
         clang::DeclContext *decl_ctx;
-        dw_offset_t die_offset = die->GetAttributeValueAsUnsigned(this, curr_cu, DW_AT_specification, DW_INVALID_OFFSET);
+        dw_offset_t die_offset = die->GetAttributeValueAsReference(this, curr_cu, DW_AT_specification, DW_INVALID_OFFSET);
         if (die_offset != DW_INVALID_OFFSET)
         {
             //printf ("SymbolFileDWARF::GetClangDeclContextForDIE ( die = 0x%8.8x ) check DW_AT_specification 0x%8.8x\n", decl_die->GetOffset(), die_offset);
@@ -2784,7 +2853,7 @@
                 return decl_ctx;
         }
 
-        die_offset = die->GetAttributeValueAsUnsigned(this, curr_cu, DW_AT_abstract_origin, DW_INVALID_OFFSET);
+        die_offset = die->GetAttributeValueAsReference(this, curr_cu, DW_AT_abstract_origin, DW_INVALID_OFFSET);
         if (die_offset != DW_INVALID_OFFSET)
         {
             //printf ("SymbolFileDWARF::GetClangDeclContextForDIE ( die = 0x%8.8x ) check DW_AT_abstract_origin 0x%8.8x\n", decl_die->GetOffset(), die_offset);
@@ -3182,6 +3251,7 @@
                         // When the definition needs to be defined.
                         m_forward_decl_die_to_clang_type[die] = clang_type;
                         m_forward_decl_clang_type_to_die[ClangASTType::RemoveFastQualifiers (clang_type)] = die;
+                        ClangASTContext::SetHasExternalStorage (clang_type, true);
                     }
                     
                 }
@@ -3244,7 +3314,7 @@
                                                                                                   DW_ATE_signed, 
                                                                                                   byte_size * 8);
                             clang_type = ast.CreateEnumerationType (type_name_cstr, 
-                                                                    GetClangDeclContextForDIE (dwarf_cu, die->GetParent()), 
+                                                                    GetClangDeclContextForDIE (dwarf_cu, die), 
                                                                     decl,
                                                                     enumerator_clang_type);
                         }
@@ -3268,6 +3338,7 @@
                         
                         m_die_to_type[die] = type_sp.get();
 
+#if LEAVE_ENUMS_FORWARD_DECLARED
                         // Leave this as a forward declaration until we need
                         // to know the details of the type. lldb_private::Type
                         // will automatically call the SymbolFile virtual function
@@ -3275,7 +3346,16 @@
                         // When the definition needs to be defined.
                         m_forward_decl_die_to_clang_type[die] = clang_type;
                         m_forward_decl_clang_type_to_die[ClangASTType::RemoveFastQualifiers (clang_type)] = die;
-
+                        ClangASTContext::SetHasExternalStorage (clang_type, true);
+#else
+                        ast.StartTagDeclarationDefinition (clang_type);
+                        if (die->HasChildren())
+                        {
+                            SymbolContext sc(GetCompUnitForDWARFCompUnit(dwarf_cu));
+                            ParseChildEnumerators(sc, clang_type, type_sp->GetByteSize(), dwarf_cu, die);
+                        }
+                        ast.CompleteTagDeclarationDefinition (clang_type);
+#endif
                     }
                 }
                 break;
@@ -4165,3 +4245,21 @@
     return NULL;
 }
 
+void
+SymbolFileDWARF::CompleteTagDecl (void *baton, clang::TagDecl *decl)
+{
+    SymbolFileDWARF *symbol_file_dwarf = (SymbolFileDWARF *)baton;
+    clang_type_t clang_type = symbol_file_dwarf->GetClangASTContext().GetTypeForDecl (decl);
+    if (clang_type)
+        symbol_file_dwarf->ResolveClangOpaqueTypeDefinition (clang_type);
+}
+
+void
+SymbolFileDWARF::CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *decl)
+{
+    SymbolFileDWARF *symbol_file_dwarf = (SymbolFileDWARF *)baton;
+    clang_type_t clang_type = symbol_file_dwarf->GetClangASTContext().GetTypeForDecl (decl);
+    if (clang_type)
+        symbol_file_dwarf->ResolveClangOpaqueTypeDefinition (clang_type);
+}
+

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Sun Jan 16 21:46:26 2011
@@ -26,7 +26,6 @@
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Core/Flags.h"
 #include "lldb/Core/UniqueCStringMap.h"
-#include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Symbol/SymbolContext.h"
 
@@ -81,6 +80,7 @@
     virtual                 ~SymbolFileDWARF();
 
     virtual uint32_t        GetAbilities ();
+    virtual void            InitializeObject();
 
     //------------------------------------------------------------------
     // Compile Unit function calls
@@ -108,12 +108,25 @@
     virtual uint32_t        FindFunctions(const lldb_private::ConstString &name, uint32_t name_type_mask, bool append, lldb_private::SymbolContextList& sc_list);
     virtual uint32_t        FindFunctions(const lldb_private::RegularExpression& regex, bool append, lldb_private::SymbolContextList& sc_list);
     virtual uint32_t        FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, bool append, uint32_t max_matches, lldb_private::TypeList& types);
-//  virtual uint32_t        FindTypes(const lldb_private::SymbolContext& sc, const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb::Type::Encoding encoding, lldb::user_id_t udt_uid, lldb_private::TypeList& types);
-    virtual lldb_private::TypeList *GetTypeList ();
+    virtual lldb_private::TypeList *
+                            GetTypeList ();
+    virtual lldb_private::ClangASTContext &
+                            GetClangASTContext ();
+
     virtual lldb_private::ClangNamespaceDecl
             FindNamespace (const lldb_private::SymbolContext& sc, 
                            const lldb_private::ConstString &name);
 
+
+    //------------------------------------------------------------------
+    // ClangASTContext callbacks for external source lookups.
+    //------------------------------------------------------------------
+    static void
+    CompleteTagDecl (void *baton, clang::TagDecl *);
+    
+    static void
+    CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *);
+
     //------------------------------------------------------------------
     // PluginInterface protocol
     //------------------------------------------------------------------
@@ -186,6 +199,9 @@
         return m_flags;
     }
 
+    bool
+    HasForwardDeclForClangType (lldb::clang_type_t clang_type);
+
 protected:
 
     enum
@@ -301,9 +317,6 @@
                                 m_debug_map_symfile = debug_map_symfile;
                             }
 
-    lldb_private::ClangASTContext &
-    GetClangASTContext();
-
     clang::NamespaceDecl *
     ResolveNamespaceDIE (DWARFCompileUnit *curr_cu, const DWARFDebugInfoEntry *die);
     
@@ -333,7 +346,8 @@
     NameToDIE                           m_global_index;                 // Global and static variables
     NameToDIE                           m_type_index;                  // All type DIE offsets
     NameToDIE                           m_namespace_index;              // All type DIE offsets
-    bool m_indexed;
+    bool m_indexed:1,
+         m_is_external_ast_source:1;
 
     std::auto_ptr<DWARFDebugRanges>     m_ranges;
 

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Sun Jan 16 21:46:26 2011
@@ -15,6 +15,8 @@
 #include "lldb/Core/RegularExpression.h"
 #include "lldb/Core/StreamFile.h"
 #include "lldb/Core/Timer.h"
+
+#include "lldb/Symbol/ClangExternalASTSourceCallbacks.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/SymbolVendor.h"
 #include "lldb/Symbol/VariableList.h"
@@ -72,12 +74,20 @@
 {
 }
 
-lldb_private::ClangASTContext &       
-SymbolFileDWARFDebugMap::GetClangASTContext ()
+void
+SymbolFileDWARFDebugMap::InitializeObject()
 {
-    return GetTypeList()->GetClangASTContext();
+    // Install our external AST source callbacks so we can complete Clang types.
+    llvm::OwningPtr<clang::ExternalASTSource> ast_source_ap (
+        new ClangExternalASTSourceCallbacks (SymbolFileDWARFDebugMap::CompleteTagDecl,
+                                             SymbolFileDWARFDebugMap::CompleteObjCInterfaceDecl,
+                                             this));
+
+    GetClangASTContext().SetExternalSource (ast_source_ap);
 }
 
+
+
 void
 SymbolFileDWARFDebugMap::InitOSO ()
 {
@@ -1093,3 +1103,44 @@
     }
 }
 
+
+void
+SymbolFileDWARFDebugMap::CompleteTagDecl (void *baton, clang::TagDecl *decl)
+{
+    SymbolFileDWARFDebugMap *symbol_file_dwarf = (SymbolFileDWARFDebugMap *)baton;
+    clang_type_t clang_type = symbol_file_dwarf->GetClangASTContext().GetTypeForDecl (decl);
+    if (clang_type)
+    {
+        SymbolFileDWARF *oso_dwarf;
+
+        for (uint32_t oso_idx = 0; ((oso_dwarf = symbol_file_dwarf->GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx)
+        {
+            if (oso_dwarf->HasForwardDeclForClangType (clang_type))
+            {
+                oso_dwarf->ResolveClangOpaqueTypeDefinition (clang_type);
+                return;
+            }
+        }
+    }
+}
+
+void
+SymbolFileDWARFDebugMap::CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *decl)
+{
+    SymbolFileDWARFDebugMap *symbol_file_dwarf = (SymbolFileDWARFDebugMap *)baton;
+    clang_type_t clang_type = symbol_file_dwarf->GetClangASTContext().GetTypeForDecl (decl);
+    if (clang_type)
+    {
+        SymbolFileDWARF *oso_dwarf;
+
+        for (uint32_t oso_idx = 0; ((oso_dwarf = symbol_file_dwarf->GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx)
+        {
+            if (oso_dwarf->HasForwardDeclForClangType (clang_type))
+            {
+                oso_dwarf->ResolveClangOpaqueTypeDefinition (clang_type);
+                return;
+            }
+        }
+    }
+}
+

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Sun Jan 16 21:46:26 2011
@@ -48,6 +48,8 @@
 
     virtual uint32_t        GetAbilities ();
 
+    virtual void            InitializeObject();
+
     //------------------------------------------------------------------
     // Compile Unit function calls
     //------------------------------------------------------------------
@@ -70,11 +72,20 @@
     virtual uint32_t        FindFunctions (const lldb_private::ConstString &name, uint32_t name_type_mask, bool append, lldb_private::SymbolContextList& sc_list);
     virtual uint32_t        FindFunctions (const lldb_private::RegularExpression& regex, bool append, lldb_private::SymbolContextList& sc_list);
     virtual uint32_t        FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, bool append, uint32_t max_matches, lldb_private::TypeList& types);
-//  virtual uint32_t        FindTypes (const lldb_private::SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, Type::Encoding encoding, lldb::user_id_t udt_uid, TypeList& types);
     virtual lldb_private::ClangNamespaceDecl
             FindNamespace (const lldb_private::SymbolContext& sc, 
                            const lldb_private::ConstString &name);
 
+
+    //------------------------------------------------------------------
+    // ClangASTContext callbacks for external source lookups.
+    //------------------------------------------------------------------
+    static void
+    CompleteTagDecl (void *baton, clang::TagDecl *);
+    
+    static void
+    CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *);
+
     //------------------------------------------------------------------
     // PluginInterface protocol
     //------------------------------------------------------------------
@@ -200,9 +211,6 @@
                               const DWARFDebugInfoEntry *die, 
                               const lldb_private::ConstString &type_name);    
 
-    lldb_private::ClangASTContext &       
-    GetClangASTContext ();
-
     //------------------------------------------------------------------
     // Member Variables
     //------------------------------------------------------------------

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Sun Jan 16 21:46:26 2011
@@ -14,7 +14,24 @@
 #include <string>
 
 // Other libraries and framework includes
+
+// Clang headers like to use NDEBUG inside of them to enable/disable debug 
+// releated features using "#ifndef NDEBUG" preprocessor blocks to do one thing
+// or another. This is bad because it means that if clang was built in release
+// mode, it assumes that you are building in release mode which is not always
+// the case. You can end up with functions that are defined as empty in header
+// files when NDEBUG is not defined, and this can cause link errors with the
+// clang .a files that you have since you might be missing functions in the .a
+// file. So we have to define NDEBUG when including clang headers to avoid any
+// mismatches. This is covered by rdar://problem/8691220
+
+#ifndef NDEBUG
+#define LLDB_DEFINED_NDEBUG_FOR_CLANG
 #define NDEBUG
+// Need to include assert.h so it is as clang would expect it to be (disabled)
+#include <assert.h>
+#endif
+
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTImporter.h"
 #include "clang/AST/CXXInheritance.h"
@@ -29,7 +46,13 @@
 #include "clang/Basic/TargetOptions.h"
 #include "clang/Frontend/FrontendOptions.h"
 #include "clang/Frontend/LangStandard.h"
+
+#ifdef LLDB_DEFINED_NDEBUG_FOR_CLANG
 #undef NDEBUG
+#undef LLDB_DEFINED_NDEBUG_FOR_CLANG
+// Need to re-include assert.h so it is as _we_ would expect it to be (enabled)
+#include <assert.h>
+#endif
 
 #include "lldb/Core/dwarf.h"
 #include "lldb/Core/Flags.h"
@@ -42,6 +65,76 @@
 using namespace llvm;
 using namespace clang;
 
+
+static bool
+GetCompleteQualType (clang::ASTContext *ast, clang::QualType qual_type)
+{
+    const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+    switch (type_class)
+    {
+    case clang::Type::Record:
+    case clang::Type::Enum:
+        {
+            clang::TagType *tag_type = dyn_cast<clang::TagType>(qual_type.getTypePtr());
+            if (tag_type)
+            {
+                clang::TagDecl *tag_decl = tag_type->getDecl();
+                if (tag_decl)
+                {
+                    if (tag_decl->getDefinition())
+                        return true;
+
+                    if (tag_decl->hasExternalLexicalStorage())
+                    {
+                        ExternalASTSource *external_ast_source = ast->getExternalSource();
+                        if (external_ast_source)
+                        {
+                            external_ast_source->CompleteType(tag_decl);
+                            return !tag_type->isIncompleteType();
+                        }
+                    }
+                    return false;
+                }
+            }
+
+        }
+        break;
+
+    case clang::Type::ObjCObject:
+    case clang::Type::ObjCInterface:
+        {
+            clang::ObjCObjectType *objc_class_type = dyn_cast<clang::ObjCObjectType>(qual_type);
+            if (objc_class_type)
+            {
+                clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+                // We currently can't complete objective C types through the newly added ASTContext
+                // because it only supports TagDecl objects right now...
+                bool is_forward_decl = class_interface_decl->isForwardDecl();
+                if (is_forward_decl && class_interface_decl->hasExternalLexicalStorage())
+                {
+                    ExternalASTSource *external_ast_source = ast->getExternalSource();
+                    if (external_ast_source)
+                    {
+                        external_ast_source->CompleteType (class_interface_decl);
+                        is_forward_decl = class_interface_decl->isForwardDecl();
+                    }
+                }
+                return is_forward_decl;
+            }
+        }
+        break;
+
+    case clang::Type::Typedef:
+        return GetCompleteQualType (ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType());
+
+    default:
+        break;
+    }
+
+    return true;
+}
+
+
 static AccessSpecifier
 ConvertAccessTypeToAccessSpecifier (AccessType access)
 {
@@ -100,7 +193,7 @@
         switch (IK) {
             case IK_None:
             case IK_AST:
-                assert(0 && "Invalid input kind!");
+                assert (!"Invalid input kind!");
             case IK_OpenCL:
                 LangStd = LangStandard::lang_opencl;
                 break;
@@ -237,9 +330,9 @@
 }
 
 
-ClangASTContext::ClangASTContext(const char *target_triple) :
+ClangASTContext::ClangASTContext (const char *target_triple) :   
     m_target_triple(),
-    m_ast_context_ap(),
+    m_ast_ap(),
     m_language_options_ap(),
     m_source_manager_ap(),
     m_diagnostic_ap(),
@@ -247,7 +340,11 @@
     m_target_info_ap(),
     m_identifier_table_ap(),
     m_selector_table_ap(),
-    m_builtins_ap()
+    m_builtins_ap(),
+    m_callback_tag_decl (NULL),
+    m_callback_objc_decl (NULL),
+    m_callback_baton (NULL)
+
 {
     if (target_triple && target_triple[0])
         m_target_triple.assign (target_triple);
@@ -266,14 +363,14 @@
     m_diagnostic_ap.reset();
     m_source_manager_ap.reset();
     m_language_options_ap.reset();
-    m_ast_context_ap.reset();
+    m_ast_ap.reset();
 }
 
 
 void
 ClangASTContext::Clear()
 {
-    m_ast_context_ap.reset();
+    m_ast_ap.reset();
     m_language_options_ap.reset();
     m_source_manager_ap.reset();
     m_diagnostic_ap.reset();
@@ -297,25 +394,65 @@
     m_target_triple.assign(target_triple);
 }
 
+bool
+ClangASTContext::HasExternalSource ()
+{
+    ASTContext *ast = getASTContext();
+    if (ast)
+        return ast->getExternalSource () != NULL;
+    return false;
+}
+
+void
+ClangASTContext::SetExternalSource (llvm::OwningPtr<ExternalASTSource> &ast_source_ap)
+{
+    ASTContext *ast = getASTContext();
+    if (ast)
+    {
+        ast->setExternalSource (ast_source_ap);
+        ast->getTranslationUnitDecl()->setHasExternalLexicalStorage(true);
+        //ast->getTranslationUnitDecl()->setHasExternalVisibleStorage(true);
+    }
+}
+
+void
+ClangASTContext::RemoveExternalSource ()
+{
+    ASTContext *ast = getASTContext();
+    
+    if (ast)
+    {
+        llvm::OwningPtr<ExternalASTSource> empty_ast_source_ap;
+        ast->setExternalSource (empty_ast_source_ap);
+        ast->getTranslationUnitDecl()->setHasExternalLexicalStorage(false);
+        //ast->getTranslationUnitDecl()->setHasExternalVisibleStorage(false);
+    }
+}
+
+
 
 ASTContext *
 ClangASTContext::getASTContext()
 {
-    if (m_ast_context_ap.get() == NULL)
+    if (m_ast_ap.get() == NULL)
     {
-        m_ast_context_ap.reset(
-            new ASTContext(
-                *getLanguageOptions(),
-                *getSourceManager(),
-                *getTargetInfo(),
-                *getIdentifierTable(),
-                *getSelectorTable(),
-                *getBuiltinContext(),
-                0));
+        m_ast_ap.reset(new ASTContext (*getLanguageOptions(),
+                                       *getSourceManager(),
+                                       *getTargetInfo(),
+                                       *getIdentifierTable(),
+                                       *getSelectorTable(),
+                                       *getBuiltinContext(),
+                                       0));
+        
+        if ((m_callback_tag_decl || m_callback_objc_decl) && m_callback_baton)
+        {
+            m_ast_ap->getTranslationUnitDecl()->setHasExternalLexicalStorage();
+            //m_ast_ap->getTranslationUnitDecl()->setHasExternalVisibleStorage();
+        }
         
-        m_ast_context_ap->getDiagnostics().setClient(getDiagnosticClient(), false);
+        m_ast_ap->getDiagnostics().setClient(getDiagnosticClient(), false);
     }
-    return m_ast_context_ap.get();
+    return m_ast_ap.get();
 }
 
 Builtin::Context *
@@ -440,9 +577,9 @@
 #pragma mark Basic Types
 
 static inline bool
-QualTypeMatchesBitSize(const uint64_t bit_size, ASTContext *ast_context, QualType qual_type)
+QualTypeMatchesBitSize(const uint64_t bit_size, ASTContext *ast, QualType qual_type)
 {
-    uint64_t qual_type_bit_size = ast_context->getTypeSize(qual_type);
+    uint64_t qual_type_bit_size = ast->getTypeSize(qual_type);
     if (qual_type_bit_size == bit_size)
         return true;
     return false;
@@ -451,63 +588,63 @@
 clang_type_t
 ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (Encoding encoding, uint32_t bit_size)
 {
-    ASTContext *ast_context = getASTContext();
+    ASTContext *ast = getASTContext();
 
-    assert (ast_context != NULL);
+    assert (ast != NULL);
 
-    return GetBuiltinTypeForEncodingAndBitSize (ast_context, encoding, bit_size);
+    return GetBuiltinTypeForEncodingAndBitSize (ast, encoding, bit_size);
 }
 
 clang_type_t
-ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (ASTContext *ast_context, Encoding encoding, uint32_t bit_size)
+ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (ASTContext *ast, Encoding encoding, uint32_t bit_size)
 {
-    if (!ast_context)
+    if (!ast)
         return NULL;
     
     switch (encoding)
     {
     case eEncodingInvalid:
-        if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->VoidPtrTy))
-            return ast_context->VoidPtrTy.getAsOpaquePtr();
+        if (QualTypeMatchesBitSize (bit_size, ast, ast->VoidPtrTy))
+            return ast->VoidPtrTy.getAsOpaquePtr();
         break;
         
     case eEncodingUint:
-        if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedCharTy))
-            return ast_context->UnsignedCharTy.getAsOpaquePtr();
-        if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedShortTy))
-            return ast_context->UnsignedShortTy.getAsOpaquePtr();
-        if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedIntTy))
-            return ast_context->UnsignedIntTy.getAsOpaquePtr();
-        if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedLongTy))
-            return ast_context->UnsignedLongTy.getAsOpaquePtr();
-        if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedLongLongTy))
-            return ast_context->UnsignedLongLongTy.getAsOpaquePtr();
-        if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedInt128Ty))
-            return ast_context->UnsignedInt128Ty.getAsOpaquePtr();
+        if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedCharTy))
+            return ast->UnsignedCharTy.getAsOpaquePtr();
+        if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedShortTy))
+            return ast->UnsignedShortTy.getAsOpaquePtr();
+        if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedIntTy))
+            return ast->UnsignedIntTy.getAsOpaquePtr();
+        if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongTy))
+            return ast->UnsignedLongTy.getAsOpaquePtr();
+        if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongLongTy))
+            return ast->UnsignedLongLongTy.getAsOpaquePtr();
+        if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedInt128Ty))
+            return ast->UnsignedInt128Ty.getAsOpaquePtr();
         break;
         
     case eEncodingSint:
-        if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->CharTy))
-            return ast_context->CharTy.getAsOpaquePtr();
-        if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->ShortTy))
-            return ast_context->ShortTy.getAsOpaquePtr();
-        if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->IntTy))
-            return ast_context->IntTy.getAsOpaquePtr();
-        if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->LongTy))
-            return ast_context->LongTy.getAsOpaquePtr();
-        if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->LongLongTy))
-            return ast_context->LongLongTy.getAsOpaquePtr();
-        if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->Int128Ty))
-            return ast_context->Int128Ty.getAsOpaquePtr();
+        if (QualTypeMatchesBitSize (bit_size, ast, ast->CharTy))
+            return ast->CharTy.getAsOpaquePtr();
+        if (QualTypeMatchesBitSize (bit_size, ast, ast->ShortTy))
+            return ast->ShortTy.getAsOpaquePtr();
+        if (QualTypeMatchesBitSize (bit_size, ast, ast->IntTy))
+            return ast->IntTy.getAsOpaquePtr();
+        if (QualTypeMatchesBitSize (bit_size, ast, ast->LongTy))
+            return ast->LongTy.getAsOpaquePtr();
+        if (QualTypeMatchesBitSize (bit_size, ast, ast->LongLongTy))
+            return ast->LongLongTy.getAsOpaquePtr();
+        if (QualTypeMatchesBitSize (bit_size, ast, ast->Int128Ty))
+            return ast->Int128Ty.getAsOpaquePtr();
         break;
         
     case eEncodingIEEE754:
-        if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->FloatTy))
-            return ast_context->FloatTy.getAsOpaquePtr();
-        if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->DoubleTy))
-            return ast_context->DoubleTy.getAsOpaquePtr();
-        if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->LongDoubleTy))
-            return ast_context->LongDoubleTy.getAsOpaquePtr();
+        if (QualTypeMatchesBitSize (bit_size, ast, ast->FloatTy))
+            return ast->FloatTy.getAsOpaquePtr();
+        if (QualTypeMatchesBitSize (bit_size, ast, ast->DoubleTy))
+            return ast->DoubleTy.getAsOpaquePtr();
+        if (QualTypeMatchesBitSize (bit_size, ast, ast->LongDoubleTy))
+            return ast->LongDoubleTy.getAsOpaquePtr();
         break;
         
     case eEncodingVector:
@@ -521,11 +658,11 @@
 clang_type_t
 ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name, uint32_t dw_ate, uint32_t bit_size)
 {
-    ASTContext *ast_context = getASTContext();
+    ASTContext *ast = getASTContext();
 
     #define streq(a,b) strcmp(a,b) == 0
-    assert (ast_context != NULL);
-    if (ast_context)
+    assert (ast != NULL);
+    if (ast)
     {
         switch (dw_ate)
         {
@@ -533,19 +670,19 @@
             break;
 
         case DW_ATE_address:
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->VoidPtrTy))
-                return ast_context->VoidPtrTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->VoidPtrTy))
+                return ast->VoidPtrTy.getAsOpaquePtr();
             break;
 
         case DW_ATE_boolean:
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->BoolTy))
-                return ast_context->BoolTy.getAsOpaquePtr();
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedCharTy))
-                return ast_context->UnsignedCharTy.getAsOpaquePtr();
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedShortTy))
-                return ast_context->UnsignedShortTy.getAsOpaquePtr();
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedIntTy))
-                return ast_context->UnsignedIntTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->BoolTy))
+                return ast->BoolTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedCharTy))
+                return ast->UnsignedCharTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedShortTy))
+                return ast->UnsignedShortTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedIntTy))
+                return ast->UnsignedIntTy.getAsOpaquePtr();
             break;
 
         case DW_ATE_lo_user:
@@ -553,31 +690,31 @@
             if (strcmp(type_name, "complex") == 0)
             {
                 clang_type_t complex_int_clang_type = GetBuiltinTypeForDWARFEncodingAndBitSize ("int", DW_ATE_signed, bit_size/2);
-                return ast_context->getComplexType (QualType::getFromOpaquePtr(complex_int_clang_type)).getAsOpaquePtr();
+                return ast->getComplexType (QualType::getFromOpaquePtr(complex_int_clang_type)).getAsOpaquePtr();
             }
             break;
             
         case DW_ATE_complex_float:
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->FloatComplexTy))
-                return ast_context->FloatComplexTy.getAsOpaquePtr();
-            else if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->DoubleComplexTy))
-                return ast_context->DoubleComplexTy.getAsOpaquePtr();
-            else if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->LongDoubleComplexTy))
-                return ast_context->LongDoubleComplexTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->FloatComplexTy))
+                return ast->FloatComplexTy.getAsOpaquePtr();
+            else if (QualTypeMatchesBitSize (bit_size, ast, ast->DoubleComplexTy))
+                return ast->DoubleComplexTy.getAsOpaquePtr();
+            else if (QualTypeMatchesBitSize (bit_size, ast, ast->LongDoubleComplexTy))
+                return ast->LongDoubleComplexTy.getAsOpaquePtr();
             else 
             {
                 clang_type_t complex_float_clang_type = GetBuiltinTypeForDWARFEncodingAndBitSize ("float", DW_ATE_float, bit_size/2);
-                return ast_context->getComplexType (QualType::getFromOpaquePtr(complex_float_clang_type)).getAsOpaquePtr();
+                return ast->getComplexType (QualType::getFromOpaquePtr(complex_float_clang_type)).getAsOpaquePtr();
             }
             break;
 
         case DW_ATE_float:
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->FloatTy))
-                return ast_context->FloatTy.getAsOpaquePtr();
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->DoubleTy))
-                return ast_context->DoubleTy.getAsOpaquePtr();
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->LongDoubleTy))
-                return ast_context->LongDoubleTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->FloatTy))
+                return ast->FloatTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->DoubleTy))
+                return ast->DoubleTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->LongDoubleTy))
+                return ast->LongDoubleTy.getAsOpaquePtr();
             break;
 
         case DW_ATE_signed:
@@ -585,52 +722,52 @@
             {
                 if (strstr(type_name, "long long"))
                 {
-                    if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->LongLongTy))
-                        return ast_context->LongLongTy.getAsOpaquePtr();
+                    if (QualTypeMatchesBitSize (bit_size, ast, ast->LongLongTy))
+                        return ast->LongLongTy.getAsOpaquePtr();
                 }
                 else if (strstr(type_name, "long"))
                 {
-                    if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->LongTy))
-                        return ast_context->LongTy.getAsOpaquePtr();
+                    if (QualTypeMatchesBitSize (bit_size, ast, ast->LongTy))
+                        return ast->LongTy.getAsOpaquePtr();
                 }
                 else if (strstr(type_name, "short"))
                 {
-                    if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->ShortTy))
-                        return ast_context->ShortTy.getAsOpaquePtr();
+                    if (QualTypeMatchesBitSize (bit_size, ast, ast->ShortTy))
+                        return ast->ShortTy.getAsOpaquePtr();
                 }
                 else if (strstr(type_name, "char"))
                 {
-                    if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->CharTy))
-                        return ast_context->CharTy.getAsOpaquePtr();
-                    if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->SignedCharTy))
-                        return ast_context->SignedCharTy.getAsOpaquePtr();
+                    if (QualTypeMatchesBitSize (bit_size, ast, ast->CharTy))
+                        return ast->CharTy.getAsOpaquePtr();
+                    if (QualTypeMatchesBitSize (bit_size, ast, ast->SignedCharTy))
+                        return ast->SignedCharTy.getAsOpaquePtr();
                 }
                 else if (strstr(type_name, "int"))
                 {
-                    if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->IntTy))
-                        return ast_context->IntTy.getAsOpaquePtr();
-                    if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->Int128Ty))
-                        return ast_context->Int128Ty.getAsOpaquePtr();
+                    if (QualTypeMatchesBitSize (bit_size, ast, ast->IntTy))
+                        return ast->IntTy.getAsOpaquePtr();
+                    if (QualTypeMatchesBitSize (bit_size, ast, ast->Int128Ty))
+                        return ast->Int128Ty.getAsOpaquePtr();
                 }
                 else if (streq(type_name, "wchar_t"))
                 {
-                    if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->WCharTy))
-                        return ast_context->WCharTy.getAsOpaquePtr();
+                    if (QualTypeMatchesBitSize (bit_size, ast, ast->WCharTy))
+                        return ast->WCharTy.getAsOpaquePtr();
                 }
             }
             // We weren't able to match up a type name, just search by size
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->CharTy))
-                return ast_context->CharTy.getAsOpaquePtr();
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->ShortTy))
-                return ast_context->ShortTy.getAsOpaquePtr();
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->IntTy))
-                return ast_context->IntTy.getAsOpaquePtr();
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->LongTy))
-                return ast_context->LongTy.getAsOpaquePtr();
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->LongLongTy))
-                return ast_context->LongLongTy.getAsOpaquePtr();
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->Int128Ty))
-                return ast_context->Int128Ty.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->CharTy))
+                return ast->CharTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->ShortTy))
+                return ast->ShortTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->IntTy))
+                return ast->IntTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->LongTy))
+                return ast->LongTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->LongLongTy))
+                return ast->LongLongTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->Int128Ty))
+                return ast->Int128Ty.getAsOpaquePtr();
             break;
 
         case DW_ATE_signed_char:
@@ -638,14 +775,14 @@
             {
                 if (streq(type_name, "signed char"))
                 {
-                    if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->SignedCharTy))
-                        return ast_context->SignedCharTy.getAsOpaquePtr();
+                    if (QualTypeMatchesBitSize (bit_size, ast, ast->SignedCharTy))
+                        return ast->SignedCharTy.getAsOpaquePtr();
                 }
             }
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->CharTy))
-                return ast_context->CharTy.getAsOpaquePtr();
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->SignedCharTy))
-                return ast_context->SignedCharTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->CharTy))
+                return ast->CharTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->SignedCharTy))
+                return ast->SignedCharTy.getAsOpaquePtr();
             break;
 
         case DW_ATE_unsigned:
@@ -653,50 +790,50 @@
             {
                 if (strstr(type_name, "long long"))
                 {
-                    if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedLongLongTy))
-                        return ast_context->UnsignedLongLongTy.getAsOpaquePtr();
+                    if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongLongTy))
+                        return ast->UnsignedLongLongTy.getAsOpaquePtr();
                 }
                 else if (strstr(type_name, "long"))
                 {
-                    if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedLongTy))
-                        return ast_context->UnsignedLongTy.getAsOpaquePtr();
+                    if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongTy))
+                        return ast->UnsignedLongTy.getAsOpaquePtr();
                 }
                 else if (strstr(type_name, "short"))
                 {
-                    if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedShortTy))
-                        return ast_context->UnsignedShortTy.getAsOpaquePtr();
+                    if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedShortTy))
+                        return ast->UnsignedShortTy.getAsOpaquePtr();
                 }
                 else if (strstr(type_name, "char"))
                 {
-                    if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedCharTy))
-                        return ast_context->UnsignedCharTy.getAsOpaquePtr();
+                    if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedCharTy))
+                        return ast->UnsignedCharTy.getAsOpaquePtr();
                 }
                 else if (strstr(type_name, "int"))
                 {
-                    if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedIntTy))
-                        return ast_context->UnsignedIntTy.getAsOpaquePtr();
-                    if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedInt128Ty))
-                        return ast_context->UnsignedInt128Ty.getAsOpaquePtr();
+                    if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedIntTy))
+                        return ast->UnsignedIntTy.getAsOpaquePtr();
+                    if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedInt128Ty))
+                        return ast->UnsignedInt128Ty.getAsOpaquePtr();
                 }
             }
             // We weren't able to match up a type name, just search by size
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedCharTy))
-                return ast_context->UnsignedCharTy.getAsOpaquePtr();
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedShortTy))
-                return ast_context->UnsignedShortTy.getAsOpaquePtr();
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedIntTy))
-                return ast_context->UnsignedIntTy.getAsOpaquePtr();
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedLongTy))
-                return ast_context->UnsignedLongTy.getAsOpaquePtr();
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedLongLongTy))
-                return ast_context->UnsignedLongLongTy.getAsOpaquePtr();
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedInt128Ty))
-                return ast_context->UnsignedInt128Ty.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedCharTy))
+                return ast->UnsignedCharTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedShortTy))
+                return ast->UnsignedShortTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedIntTy))
+                return ast->UnsignedIntTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongTy))
+                return ast->UnsignedLongTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongLongTy))
+                return ast->UnsignedLongLongTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedInt128Ty))
+                return ast->UnsignedInt128Ty.getAsOpaquePtr();
             break;
 
         case DW_ATE_unsigned_char:
-            if (QualTypeMatchesBitSize (bit_size, ast_context, ast_context->UnsignedCharTy))
-                return ast_context->UnsignedCharTy.getAsOpaquePtr();
+            if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedCharTy))
+                return ast->UnsignedCharTy.getAsOpaquePtr();
             break;
 
         case DW_ATE_imaginary_float:
@@ -710,9 +847,9 @@
 }
 
 clang_type_t
-ClangASTContext::GetBuiltInType_void(ASTContext *ast_context)
+ClangASTContext::GetBuiltInType_void(ASTContext *ast)
 {
-    return ast_context->VoidTy.getAsOpaquePtr();
+    return ast->VoidTy.getAsOpaquePtr();
 }
 
 clang_type_t
@@ -757,9 +894,9 @@
 }
 
 clang_type_t
-ClangASTContext::GetVoidPtrType (ASTContext *ast_context, bool is_const)
+ClangASTContext::GetVoidPtrType (ASTContext *ast, bool is_const)
 {
-    QualType void_ptr_type(ast_context->VoidPtrTy);
+    QualType void_ptr_type(ast->VoidPtrTy);
     
     if (is_const)
         void_ptr_type.addConst();
@@ -798,11 +935,11 @@
 }
 
 bool
-ClangASTContext::AreTypesSame(ASTContext *ast_context,
+ClangASTContext::AreTypesSame(ASTContext *ast,
              clang_type_t type1,
              clang_type_t type2)
 {
-    return ast_context->hasSameType(QualType::getFromOpaquePtr(type1),
+    return ast->hasSameType(QualType::getFromOpaquePtr(type1),
                                     QualType::getFromOpaquePtr(type2));
 }
 
@@ -844,16 +981,39 @@
     return NULL;
 }
 
+
+clang_type_t
+ClangASTContext::GetTypeForDecl (TagDecl *decl)
+{
+    // No need to call the getASTContext() accessor (which can create the AST
+    // if it isn't created yet, because we can't have created a decl in this
+    // AST if our AST didn't already exist...
+    if (m_ast_ap.get())
+        return m_ast_ap->getTagDeclType(decl).getAsOpaquePtr();
+    return NULL;
+}
+
+clang_type_t
+ClangASTContext::GetTypeForDecl (ObjCInterfaceDecl *decl)
+{
+    // No need to call the getASTContext() accessor (which can create the AST
+    // if it isn't created yet, because we can't have created a decl in this
+    // AST if our AST didn't already exist...
+    if (m_ast_ap.get())
+        return m_ast_ap->getObjCInterfaceType(decl).getAsOpaquePtr();
+    return NULL;
+}
+
 #pragma mark Structure, Unions, Classes
 
 clang_type_t
 ClangASTContext::CreateRecordType (const char *name, int kind, DeclContext *decl_ctx, LanguageType language)
 {
-    ASTContext *ast_context = getASTContext();
-    assert (ast_context != NULL);
+    ASTContext *ast = getASTContext();
+    assert (ast != NULL);
     
     if (decl_ctx == NULL)
-        decl_ctx = ast_context->getTranslationUnitDecl();
+        decl_ctx = ast->getTranslationUnitDecl();
 
 
     if (language == eLanguageTypeObjC)
@@ -868,13 +1028,78 @@
     // the CXXRecordDecl class since we often don't know from debug information
     // if something is struct or a class, so we default to always use the more
     // complete definition just in case.
-    CXXRecordDecl *decl = CXXRecordDecl::Create(*ast_context,
+    CXXRecordDecl *decl = CXXRecordDecl::Create(*ast,
                                                 (TagDecl::TagKind)kind,
                                                 decl_ctx,
                                                 SourceLocation(),
-                                                name && name[0] ? &ast_context->Idents.get(name) : NULL);
+                                                name && name[0] ? &ast->Idents.get(name) : NULL);
 
-    return ast_context->getTagDeclType(decl).getAsOpaquePtr();
+    return ast->getTagDeclType(decl).getAsOpaquePtr();
+}
+
+bool
+ClangASTContext::SetHasExternalStorage (clang_type_t clang_type, bool has_extern)
+{
+    if (clang_type == NULL)
+        return false;
+
+    QualType qual_type (QualType::getFromOpaquePtr(clang_type));
+
+    const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+    switch (type_class)
+    {
+    case clang::Type::Record:
+        {
+            CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+            if (cxx_record_decl)
+            {
+                cxx_record_decl->setHasExternalLexicalStorage (has_extern);
+                //cxx_record_decl->setHasExternalVisibleStorage (has_extern);
+                return true;
+            }
+        }
+        break;
+
+    case clang::Type::Enum:
+        {
+            EnumDecl *enum_decl = cast<EnumType>(qual_type)->getDecl();
+            if (enum_decl)
+            {
+                enum_decl->setHasExternalLexicalStorage (has_extern);
+                //enum_decl->setHasExternalVisibleStorage (has_extern);
+                return true;
+            }
+        }
+        break;
+
+    case clang::Type::ObjCObject:
+    case clang::Type::ObjCInterface:
+        {
+            ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(qual_type.getTypePtr());
+            assert (objc_class_type);
+            if (objc_class_type)
+            {
+                ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+            
+                if (class_interface_decl)
+                {
+                    if (has_extern)
+                        class_interface_decl->setExternallyCompleted();
+                    class_interface_decl->setHasExternalLexicalStorage (has_extern);
+                    //class_interface_decl->setHasExternalVisibleStorage (has_extern);
+                    return true;
+                }
+            }
+        }
+        break;
+
+    case clang::Type::Typedef:
+        return ClangASTContext::SetHasExternalStorage (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), has_extern);
+
+    default:
+        break;
+    }
+    return false;
 }
 
 static bool
@@ -1092,10 +1317,11 @@
 
     return true;
 }
+
 CXXMethodDecl *
 ClangASTContext::AddMethodToCXXRecordType
 (
-    ASTContext *ast_context,
+    ASTContext *ast,
     clang_type_t record_opaque_type,
     const char *name,
     clang_type_t method_opaque_type,
@@ -1109,30 +1335,15 @@
     if (!record_opaque_type || !method_opaque_type || !name)
         return NULL;
     
-    assert(ast_context);
+    assert(ast);
     
-    IdentifierTable *identifier_table = &ast_context->Idents;
+    IdentifierTable *identifier_table = &ast->Idents;
     
     assert(identifier_table);
     
     QualType record_qual_type(QualType::getFromOpaquePtr(record_opaque_type));
 
-    clang::Type *clang_type(record_qual_type.getTypePtr());
-    
-    if (clang_type == NULL)
-        return NULL;
-    
-    RecordType *record_clang_type(dyn_cast<RecordType>(clang_type));
-    
-    if (record_clang_type == NULL)
-        return NULL;
-    
-    RecordDecl *record_decl = record_clang_type->getDecl();
-    
-    if (record_decl == NULL)
-        return NULL;
-    
-    CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
+    CXXRecordDecl *cxx_record_decl = record_qual_type->getAsCXXRecordDecl();
     
     if (cxx_record_decl == NULL)
         return NULL;
@@ -1159,19 +1370,19 @@
     
     if (name[0] == '~')
     {
-        cxx_method_decl = CXXDestructorDecl::Create (*ast_context,
+        cxx_method_decl = CXXDestructorDecl::Create (*ast,
                                                      cxx_record_decl,
-                                                     DeclarationNameInfo (ast_context->DeclarationNames.getCXXDestructorName (ast_context->getCanonicalType (record_qual_type)), SourceLocation()),
+                                                     DeclarationNameInfo (ast->DeclarationNames.getCXXDestructorName (ast->getCanonicalType (record_qual_type)), SourceLocation()),
                                                      method_qual_type,
                                                      NULL,
                                                      is_inline,
                                                      is_implicitly_declared);
     }
-    else if (decl_name == record_decl->getDeclName())
+    else if (decl_name == cxx_record_decl->getDeclName())
     {
-        cxx_method_decl = CXXConstructorDecl::Create (*ast_context,
+        cxx_method_decl = CXXConstructorDecl::Create (*ast,
                                                       cxx_record_decl,
-                                                      DeclarationNameInfo (ast_context->DeclarationNames.getCXXConstructorName (ast_context->getCanonicalType (record_qual_type)), SourceLocation()),
+                                                      DeclarationNameInfo (ast->DeclarationNames.getCXXConstructorName (ast->getCanonicalType (record_qual_type)), SourceLocation()),
                                                       method_qual_type,
                                                       NULL, // TypeSourceInfo *
                                                       is_explicit, 
@@ -1186,9 +1397,9 @@
         {
             if (op_kind != NUM_OVERLOADED_OPERATORS)
             {
-                cxx_method_decl = CXXMethodDecl::Create (*ast_context,
+                cxx_method_decl = CXXMethodDecl::Create (*ast,
                                                          cxx_record_decl,
-                                                         DeclarationNameInfo (ast_context->DeclarationNames.getCXXOperatorName (op_kind), SourceLocation()),
+                                                         DeclarationNameInfo (ast->DeclarationNames.getCXXOperatorName (op_kind), SourceLocation()),
                                                          method_qual_type,
                                                          NULL, // TypeSourceInfo *
                                                          is_static,
@@ -1198,9 +1409,9 @@
             else if (num_params == 0)
             {
                 // Conversion operators don't take params...
-                cxx_method_decl = CXXConversionDecl::Create (*ast_context,
+                cxx_method_decl = CXXConversionDecl::Create (*ast,
                                                              cxx_record_decl,
-                                                             DeclarationNameInfo (ast_context->DeclarationNames.getCXXConversionFunctionName (ast_context->getCanonicalType (function_Type->getResultType())), SourceLocation()),
+                                                             DeclarationNameInfo (ast->DeclarationNames.getCXXConversionFunctionName (ast->getCanonicalType (function_Type->getResultType())), SourceLocation()),
                                                              method_qual_type,
                                                              NULL, // TypeSourceInfo *
                                                              is_inline,
@@ -1210,7 +1421,7 @@
         
         if (cxx_method_decl == NULL)
         {
-            cxx_method_decl = CXXMethodDecl::Create (*ast_context,
+            cxx_method_decl = CXXMethodDecl::Create (*ast,
                                                      cxx_record_decl,
                                                      DeclarationNameInfo (decl_name, SourceLocation()),
                                                      method_qual_type,
@@ -1234,7 +1445,7 @@
          param_index < num_params;
          ++param_index)
     {
-        params[param_index] = ParmVarDecl::Create (*ast_context,
+        params[param_index] = ParmVarDecl::Create (*ast,
                                                    cxx_method_decl,
                                                    SourceLocation(),
                                                    NULL, // anonymous
@@ -1255,7 +1466,7 @@
 bool
 ClangASTContext::AddFieldToRecordType 
 (
-    ASTContext *ast_context,
+    ASTContext *ast,
     clang_type_t record_clang_type, 
     const char *name, 
     clang_type_t field_type, 
@@ -1266,9 +1477,9 @@
     if (record_clang_type == NULL || field_type == NULL)
         return false;
 
-    IdentifierTable *identifier_table = &ast_context->Idents;
+    IdentifierTable *identifier_table = &ast->Idents;
 
-    assert (ast_context != NULL);
+    assert (ast != NULL);
     assert (identifier_table != NULL);
 
     QualType record_qual_type(QualType::getFromOpaquePtr(record_clang_type));
@@ -1285,10 +1496,10 @@
             clang::Expr *bit_width = NULL;
             if (bitfield_bit_size != 0)
             {
-                APInt bitfield_bit_size_apint(ast_context->getTypeSize(ast_context->IntTy), bitfield_bit_size);
-                bit_width = new (*ast_context)IntegerLiteral (*ast_context, bitfield_bit_size_apint, ast_context->IntTy, SourceLocation());
+                APInt bitfield_bit_size_apint(ast->getTypeSize(ast->IntTy), bitfield_bit_size);
+                bit_width = new (*ast)IntegerLiteral (*ast, bitfield_bit_size_apint, ast->IntTy, SourceLocation());
             }
-            FieldDecl *field = FieldDecl::Create (*ast_context,
+            FieldDecl *field = FieldDecl::Create (*ast,
                                                   record_decl,
                                                   SourceLocation(),
                                                   name ? &identifier_table->get(name) : NULL, // Identifier
@@ -1310,7 +1521,7 @@
             if (objc_class_type)
             {
                 bool is_synthesized = false;
-                ClangASTContext::AddObjCClassIVar (ast_context,
+                ClangASTContext::AddObjCClassIVar (ast,
                                                    record_clang_type,
                                                    name,
                                                    field_type,
@@ -1332,12 +1543,12 @@
 bool
 ClangASTContext::FieldIsBitfield
 (
-    ASTContext *ast_context,
+    ASTContext *ast,
     FieldDecl* field,
     uint32_t& bitfield_bit_size
 )
 {
-    if (ast_context == NULL || field == NULL)
+    if (ast == NULL || field == NULL)
         return false;
 
     if (field->isBitField())
@@ -1346,7 +1557,7 @@
         if (bit_width_expr)
         {
             llvm::APSInt bit_width_apsint;
-            if (bit_width_expr->isIntegerConstantExpr(bit_width_apsint, *ast_context))
+            if (bit_width_expr->isIntegerConstantExpr(bit_width_apsint, *ast))
             {
                 bitfield_bit_size = bit_width_apsint.getLimitedValue(UINT32_MAX);
                 return true;
@@ -1383,30 +1594,27 @@
 }
 
 void
-ClangASTContext::SetDefaultAccessForRecordFields (clang_type_t clang_qual_type, int default_accessibility, int *assigned_accessibilities, size_t num_assigned_accessibilities)
+ClangASTContext::SetDefaultAccessForRecordFields (clang_type_t clang_type, int default_accessibility, int *assigned_accessibilities, size_t num_assigned_accessibilities)
 {
-    if (clang_qual_type)
+    if (clang_type)
     {
-        QualType qual_type(QualType::getFromOpaquePtr(clang_qual_type));
-        clang::Type *clang_type = qual_type.getTypePtr();
-        if (clang_type)
+        QualType qual_type(QualType::getFromOpaquePtr(clang_type));
+
+        RecordType *record_type = dyn_cast<RecordType>(qual_type.getTypePtr());
+        if (record_type)
         {
-            RecordType *record_type = dyn_cast<RecordType>(clang_type);
-            if (record_type)
+            RecordDecl *record_decl = record_type->getDecl();
+            if (record_decl)
             {
-                RecordDecl *record_decl = record_type->getDecl();
-                if (record_decl)
+                uint32_t field_idx;
+                RecordDecl::field_iterator field, field_end;
+                for (field = record_decl->field_begin(), field_end = record_decl->field_end(), field_idx = 0;
+                     field != field_end;
+                     ++field, ++field_idx)
                 {
-                    uint32_t field_idx;
-                    RecordDecl::field_iterator field, field_end;
-                    for (field = record_decl->field_begin(), field_end = record_decl->field_end(), field_idx = 0;
-                         field != field_end;
-                         ++field, ++field_idx)
-                    {
-                        // If no accessibility was assigned, assign the correct one
-                        if (field_idx < num_assigned_accessibilities && assigned_accessibilities[field_idx] == clang::AS_none)
-                            field->setAccess ((AccessSpecifier)default_accessibility);
-                    }
+                    // If no accessibility was assigned, assign the correct one
+                    if (field_idx < num_assigned_accessibilities && assigned_accessibilities[field_idx] == clang::AS_none)
+                        field->setAccess ((AccessSpecifier)default_accessibility);
                 }
             }
         }
@@ -1442,19 +1650,11 @@
 {
     if (class_clang_type)
     {
-        clang::Type *clang_type = QualType::getFromOpaquePtr(class_clang_type).getTypePtr();
-        if (clang_type)
+        CXXRecordDecl *cxx_record_decl = QualType::getFromOpaquePtr(class_clang_type)->getAsCXXRecordDecl();
+        if (cxx_record_decl)
         {
-            RecordType *record_type = dyn_cast<RecordType>(clang_type);
-            if (record_type)
-            {
-                CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_type->getDecl());
-                if (cxx_record_decl)
-                {
-                    cxx_record_decl->setBases(base_classes, num_base_classes);
-                    return true;
-                }
-            }
+            cxx_record_decl->setBases(base_classes, num_base_classes);
+            return true;
         }
     }
     return false;
@@ -1470,26 +1670,26 @@
     bool isInternal
 )
 {
-    ASTContext *ast_context = getASTContext();
-    assert (ast_context != NULL);
+    ASTContext *ast = getASTContext();
+    assert (ast != NULL);
     assert (name && name[0]);
     if (decl_ctx == NULL)
-        decl_ctx = ast_context->getTranslationUnitDecl();
+        decl_ctx = ast->getTranslationUnitDecl();
 
     // NOTE: Eventually CXXRecordDecl will be merged back into RecordDecl and
     // we will need to update this code. I was told to currently always use
     // the CXXRecordDecl class since we often don't know from debug information
     // if something is struct or a class, so we default to always use the more
     // complete definition just in case.
-    ObjCInterfaceDecl *decl = ObjCInterfaceDecl::Create (*ast_context,
+    ObjCInterfaceDecl *decl = ObjCInterfaceDecl::Create (*ast,
                                                          decl_ctx,
                                                          SourceLocation(),
-                                                         &ast_context->Idents.get(name),
+                                                         &ast->Idents.get(name),
                                                          SourceLocation(),
                                                          isForwardDecl,
                                                          isInternal);
     
-    return ast_context->getObjCInterfaceType(decl).getAsOpaquePtr();
+    return ast->getObjCInterfaceType(decl).getAsOpaquePtr();
 }
 
 bool
@@ -1524,7 +1724,7 @@
 bool
 ClangASTContext::AddObjCClassIVar 
 (
-    ASTContext *ast_context,
+    ASTContext *ast,
     clang_type_t class_opaque_type, 
     const char *name, 
     clang_type_t ivar_opaque_type, 
@@ -1536,9 +1736,9 @@
     if (class_opaque_type == NULL || ivar_opaque_type == NULL)
         return false;
 
-    IdentifierTable *identifier_table = &ast_context->Idents;
+    IdentifierTable *identifier_table = &ast->Idents;
 
-    assert (ast_context != NULL);
+    assert (ast != NULL);
     assert (identifier_table != NULL);
 
     QualType class_qual_type(QualType::getFromOpaquePtr(class_opaque_type));
@@ -1557,11 +1757,11 @@
                 clang::Expr *bit_width = NULL;
                 if (bitfield_bit_size != 0)
                 {
-                    APInt bitfield_bit_size_apint(ast_context->getTypeSize(ast_context->IntTy), bitfield_bit_size);
-                    bit_width = new (*ast_context)IntegerLiteral (*ast_context, bitfield_bit_size_apint, ast_context->IntTy, SourceLocation());
+                    APInt bitfield_bit_size_apint(ast->getTypeSize(ast->IntTy), bitfield_bit_size);
+                    bit_width = new (*ast)IntegerLiteral (*ast, bitfield_bit_size_apint, ast->IntTy, SourceLocation());
                 }
                 
-                ObjCIvarDecl *field = ObjCIvarDecl::Create (*ast_context,
+                ObjCIvarDecl *field = ObjCIvarDecl::Create (*ast,
                                                             class_interface_decl,
                                                             SourceLocation(),
                                                             &identifier_table->get(name), // Identifier
@@ -1618,7 +1818,7 @@
 ObjCMethodDecl *
 ClangASTContext::AddMethodToObjCObjectType
 (
-    ASTContext *ast_context,
+    ASTContext *ast,
     clang_type_t class_opaque_type, 
     const char *name,  // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]")
     clang_type_t method_opaque_type,
@@ -1628,9 +1828,9 @@
     if (class_opaque_type == NULL || method_opaque_type == NULL)
         return NULL;
 
-    IdentifierTable *identifier_table = &ast_context->Idents;
+    IdentifierTable *identifier_table = &ast->Idents;
 
-    assert (ast_context != NULL);
+    assert (ast != NULL);
     assert (identifier_table != NULL);
 
     QualType class_qual_type(QualType::getFromOpaquePtr(class_opaque_type));
@@ -1680,7 +1880,7 @@
     if (selector_idents.size() == 0)
         return 0;
 
-    clang::Selector method_selector = ast_context->Selectors.getSelector (num_selectors_with_args ? selector_idents.size() : 0, 
+    clang::Selector method_selector = ast->Selectors.getSelector (num_selectors_with_args ? selector_idents.size() : 0, 
                                                                           selector_idents.data());
     
     QualType method_qual_type (QualType::getFromOpaquePtr (method_opaque_type));
@@ -1704,7 +1904,7 @@
 
     const unsigned num_args = method_function_prototype->getNumArgs();
 
-    ObjCMethodDecl *objc_method_decl = ObjCMethodDecl::Create (*ast_context,
+    ObjCMethodDecl *objc_method_decl = ObjCMethodDecl::Create (*ast,
                                                                SourceLocation(), // beginLoc,
                                                                SourceLocation(), // endLoc, 
                                                                method_selector,
@@ -1728,7 +1928,7 @@
             
         for (int param_index = 0; param_index < num_args; ++param_index)
         {
-            params.push_back (ParmVarDecl::Create (*ast_context,
+            params.push_back (ParmVarDecl::Create (*ast,
                                                    objc_method_decl,
                                                    SourceLocation(),
                                                    NULL, // anonymous
@@ -1739,7 +1939,7 @@
                                                    NULL));
         }
         
-        objc_method_decl->setMethodParams(*ast_context, params.data(), params.size(), num_args);
+        objc_method_decl->setMethodParams(*ast, params.data(), params.size(), num_args);
     }
     
     class_interface_decl->addDecl (objc_method_decl);
@@ -1753,7 +1953,7 @@
 ClangASTContext::GetTypeInfo 
 (
     clang_type_t clang_type, 
-    clang::ASTContext *ast_context, 
+    clang::ASTContext *ast, 
     clang_type_t *pointee_or_element_clang_type
 )
 {
@@ -1773,8 +1973,8 @@
         {
         case clang::BuiltinType::ObjCId:
         case clang::BuiltinType::ObjCClass:
-            if (ast_context && pointee_or_element_clang_type)
-                *pointee_or_element_clang_type = ast_context->ObjCBuiltinClassTy.getAsOpaquePtr();
+            if (ast && pointee_or_element_clang_type)
+                *pointee_or_element_clang_type = ast->ObjCBuiltinClassTy.getAsOpaquePtr();
             return eTypeIsBuiltIn | eTypeIsPointer | eTypeHasValue;
 
         default: 
@@ -1846,7 +2046,7 @@
 
     case clang::Type::Typedef:                         
         return eTypeIsTypedef | ClangASTContext::GetTypeInfo (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
-                                                                  ast_context, 
+                                                                  ast, 
                                                                   pointee_or_element_clang_type);
 
     case clang::Type::TypeOfExpr:                       return 0;
@@ -1893,13 +2093,13 @@
 }
 
 uint32_t
-ClangASTContext::GetNumChildren (clang_type_t clang_qual_type, bool omit_empty_base_classes)
+ClangASTContext::GetNumChildren (clang::ASTContext *ast, clang_type_t clang_type, bool omit_empty_base_classes)
 {
-    if (clang_qual_type == NULL)
+    if (clang_type == NULL)
         return 0;
 
     uint32_t num_children = 0;
-    QualType qual_type(QualType::getFromOpaquePtr(clang_qual_type));
+    QualType qual_type(QualType::getFromOpaquePtr(clang_type));
     const clang::Type::TypeClass type_class = qual_type->getTypeClass();
     switch (type_class)
     {
@@ -1919,7 +2119,7 @@
     case clang::Type::Complex: return 0;
 
     case clang::Type::Record:
-        if (ClangASTType::IsDefined (clang_qual_type))
+        if (ClangASTContext::GetCompleteType (ast, clang_type))
         {
             const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr());
             const RecordDecl *record_decl = record_type->getDecl();
@@ -1994,7 +2194,8 @@
         {
             ObjCObjectPointerType *pointer_type = cast<ObjCObjectPointerType>(qual_type.getTypePtr());
             QualType pointee_type = pointer_type->getPointeeType();
-            uint32_t num_pointee_children = ClangASTContext::GetNumChildren (pointee_type.getAsOpaquePtr(), 
+            uint32_t num_pointee_children = ClangASTContext::GetNumChildren (ast,
+                                                                             pointee_type.getAsOpaquePtr(), 
                                                                              omit_empty_base_classes);
             // If this type points to a simple type, then it has 1 child
             if (num_pointee_children == 0)
@@ -2012,7 +2213,8 @@
         {
             PointerType *pointer_type = cast<PointerType>(qual_type.getTypePtr());
             QualType pointee_type (pointer_type->getPointeeType());
-            uint32_t num_pointee_children = ClangASTContext::GetNumChildren (pointee_type.getAsOpaquePtr(), 
+            uint32_t num_pointee_children = ClangASTContext::GetNumChildren (ast,
+                                                                             pointee_type.getAsOpaquePtr(), 
                                                                              omit_empty_base_classes);
             if (num_pointee_children == 0)
             {
@@ -2030,7 +2232,8 @@
         {
             ReferenceType *reference_type = cast<ReferenceType>(qual_type.getTypePtr());
             QualType pointee_type = reference_type->getPointeeType();
-            uint32_t num_pointee_children = ClangASTContext::GetNumChildren (pointee_type.getAsOpaquePtr(), 
+            uint32_t num_pointee_children = ClangASTContext::GetNumChildren (ast,
+                                                                             pointee_type.getAsOpaquePtr(), 
                                                                              omit_empty_base_classes);
             // If this type points to a simple type, then it has 1 child
             if (num_pointee_children == 0)
@@ -2042,7 +2245,9 @@
 
 
     case clang::Type::Typedef:
-        num_children = ClangASTContext::GetNumChildren (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), omit_empty_base_classes);
+        num_children = ClangASTContext::GetNumChildren (ast,
+                                                        cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), 
+                                                        omit_empty_base_classes);
         break;
 
     default:
@@ -2178,7 +2383,7 @@
 clang_type_t
 ClangASTContext::GetChildClangTypeAtIndex
 (
-    ASTContext *ast_context,
+    ASTContext *ast,
     const char *parent_name,
     clang_type_t parent_clang_type,
     uint32_t idx,
@@ -2195,7 +2400,7 @@
     if (parent_clang_type == NULL)
         return NULL;
 
-    if (idx < ClangASTContext::GetNumChildren (parent_clang_type, omit_empty_base_classes))
+    if (idx < ClangASTContext::GetNumChildren (ast, parent_clang_type, omit_empty_base_classes))
     {
         uint32_t bit_offset;
         child_bitfield_bit_size = 0;
@@ -2211,21 +2416,21 @@
             case clang::BuiltinType::ObjCId:
             case clang::BuiltinType::ObjCClass:
                 child_name = "isa";
-                child_byte_size = ast_context->getTypeSize(ast_context->ObjCBuiltinClassTy) / CHAR_BIT;
-                return ast_context->ObjCBuiltinClassTy.getAsOpaquePtr();
+                child_byte_size = ast->getTypeSize(ast->ObjCBuiltinClassTy) / CHAR_BIT;
+                return ast->ObjCBuiltinClassTy.getAsOpaquePtr();
                 
             default:
                 break;
             }
             break;
-        
 
         case clang::Type::Record:
+            if (ClangASTContext::GetCompleteType (ast, parent_clang_type))
             {
                 const RecordType *record_type = cast<RecordType>(parent_qual_type.getTypePtr());
                 const RecordDecl *record_decl = record_type->getDecl();
                 assert(record_decl);
-                const ASTRecordLayout &record_layout = ast_context->getASTRecordLayout(record_decl);
+                const ASTRecordLayout &record_layout = ast->getASTRecordLayout(record_decl);
                 uint32_t child_idx = 0;
 
                 const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
@@ -2265,7 +2470,7 @@
 
                             child_name.assign(base_class_type_name.c_str());
 
-                            uint64_t clang_type_info_bit_size = ast_context->getTypeSize(base_class->getType());
+                            uint64_t clang_type_info_bit_size = ast->getTypeSize(base_class->getType());
 
                             // Base classes biut sizes should be a multiple of 8 bits in size
                             assert (clang_type_info_bit_size % 8 == 0);
@@ -2291,7 +2496,7 @@
 
                         // Figure out the type byte size (field_type_info.first) and
                         // alignment (field_type_info.second) from the AST context.
-                        std::pair<uint64_t, unsigned> field_type_info = ast_context->getTypeInfo(field->getType());
+                        std::pair<uint64_t, unsigned> field_type_info = ast->getTypeInfo(field->getType());
                         assert(field_idx < record_layout.getFieldCount());
 
                         child_byte_size = field_type_info.first / 8;
@@ -2299,7 +2504,7 @@
                         // Figure out the field offset within the current struct/union/class type
                         bit_offset = record_layout.getFieldOffset (field_idx);
                         child_byte_offset = bit_offset / 8;
-                        if (ClangASTContext::FieldIsBitfield (ast_context, *field, child_bitfield_bit_size))
+                        if (ClangASTContext::FieldIsBitfield (ast, *field, child_bitfield_bit_size))
                             child_bitfield_bit_offset = bit_offset % 8;
 
                         return field->getType().getAsOpaquePtr();
@@ -2321,22 +2526,22 @@
                     if (class_interface_decl)
                     {
                 
-                        const ASTRecordLayout &interface_layout = ast_context->getASTObjCInterfaceLayout(class_interface_decl);
+                        const ASTRecordLayout &interface_layout = ast->getASTObjCInterfaceLayout(class_interface_decl);
                         ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
                         if (superclass_interface_decl)
                         {
                             if (omit_empty_base_classes)
                             {
-                                if (ClangASTContext::GetNumChildren(ast_context->getObjCInterfaceType(superclass_interface_decl).getAsOpaquePtr(), omit_empty_base_classes) > 0)
+                                if (ClangASTContext::GetNumChildren(ast, ast->getObjCInterfaceType(superclass_interface_decl).getAsOpaquePtr(), omit_empty_base_classes) > 0)
                                 {
                                     if (idx == 0)
                                     {
-                                        QualType ivar_qual_type(ast_context->getObjCInterfaceType(superclass_interface_decl));
+                                        QualType ivar_qual_type(ast->getObjCInterfaceType(superclass_interface_decl));
                                         
 
                                         child_name.assign(superclass_interface_decl->getNameAsString().c_str());
 
-                                        std::pair<uint64_t, unsigned> ivar_type_info = ast_context->getTypeInfo(ivar_qual_type.getTypePtr());
+                                        std::pair<uint64_t, unsigned> ivar_type_info = ast->getTypeInfo(ivar_qual_type.getTypePtr());
 
                                         child_byte_size = ivar_type_info.first / 8;
                                         child_byte_offset = 0;
@@ -2368,7 +2573,7 @@
 
                                     child_name.assign(ivar_decl->getNameAsString().c_str());
 
-                                    std::pair<uint64_t, unsigned> ivar_type_info = ast_context->getTypeInfo(ivar_qual_type.getTypePtr());
+                                    std::pair<uint64_t, unsigned> ivar_type_info = ast->getTypeInfo(ivar_qual_type.getTypePtr());
 
                                     child_byte_size = ivar_type_info.first / 8;
 
@@ -2393,7 +2598,7 @@
 
                 if (transparent_pointers && ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
                 {
-                    return GetChildClangTypeAtIndex (ast_context,
+                    return GetChildClangTypeAtIndex (ast,
                                                      parent_name,
                                                      pointer_type->getPointeeType().getAsOpaquePtr(),
                                                      idx,
@@ -2417,7 +2622,7 @@
                     // We have a pointer to an simple type
                     if (idx == 0)
                     {
-                        std::pair<uint64_t, unsigned> clang_type_info = ast_context->getTypeInfo(pointee_type);
+                        std::pair<uint64_t, unsigned> clang_type_info = ast->getTypeInfo(pointee_type);
                         assert(clang_type_info.first % 8 == 0);
                         child_byte_size = clang_type_info.first / 8;
                         child_byte_offset = 0;
@@ -2434,16 +2639,19 @@
 
                 if (idx < element_count)
                 {
-                    std::pair<uint64_t, unsigned> field_type_info = ast_context->getTypeInfo(array->getElementType());
+                    if (GetCompleteQualType (ast, array->getElementType()))
+                    {
+                        std::pair<uint64_t, unsigned> field_type_info = ast->getTypeInfo(array->getElementType());
 
-                    char element_name[64];
-                    ::snprintf (element_name, sizeof (element_name), "[%u]", idx);
+                        char element_name[64];
+                        ::snprintf (element_name, sizeof (element_name), "[%u]", idx);
 
-                    child_name.assign(element_name);
-                    assert(field_type_info.first % 8 == 0);
-                    child_byte_size = field_type_info.first / 8;
-                    child_byte_offset = idx * child_byte_size;
-                    return array->getElementType().getAsOpaquePtr();
+                        child_name.assign(element_name);
+                        assert(field_type_info.first % 8 == 0);
+                        child_byte_size = field_type_info.first / 8;
+                        child_byte_offset = idx * child_byte_size;
+                        return array->getElementType().getAsOpaquePtr();
+                    }
                 }
             }
             break;
@@ -2459,7 +2667,7 @@
 
                 if (transparent_pointers && ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
                 {
-                    return GetChildClangTypeAtIndex (ast_context,
+                    return GetChildClangTypeAtIndex (ast,
                                                      parent_name,
                                                      pointer_type->getPointeeType().getAsOpaquePtr(),
                                                      idx,
@@ -2483,7 +2691,7 @@
                     // We have a pointer to an simple type
                     if (idx == 0)
                     {
-                        std::pair<uint64_t, unsigned> clang_type_info = ast_context->getTypeInfo(pointee_type);
+                        std::pair<uint64_t, unsigned> clang_type_info = ast->getTypeInfo(pointee_type);
                         assert(clang_type_info.first % 8 == 0);
                         child_byte_size = clang_type_info.first / 8;
                         child_byte_offset = 0;
@@ -2501,7 +2709,7 @@
                 clang_type_t pointee_clang_type = pointee_type.getAsOpaquePtr();
                 if (transparent_pointers && ClangASTContext::IsAggregateType (pointee_clang_type))
                 {
-                    return GetChildClangTypeAtIndex (ast_context,
+                    return GetChildClangTypeAtIndex (ast,
                                                      parent_name,
                                                      pointee_clang_type,
                                                      idx,
@@ -2525,7 +2733,7 @@
                     // We have a pointer to an simple type
                     if (idx == 0)
                     {
-                        std::pair<uint64_t, unsigned> clang_type_info = ast_context->getTypeInfo(pointee_type);
+                        std::pair<uint64_t, unsigned> clang_type_info = ast->getTypeInfo(pointee_type);
                         assert(clang_type_info.first % 8 == 0);
                         child_byte_size = clang_type_info.first / 8;
                         child_byte_offset = 0;
@@ -2536,7 +2744,7 @@
             break;
 
         case clang::Type::Typedef:
-            return GetChildClangTypeAtIndex (ast_context,
+            return GetChildClangTypeAtIndex (ast,
                                              parent_name,
                                              cast<TypedefType>(parent_qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
                                              idx,
@@ -2560,7 +2768,7 @@
 static inline bool
 BaseSpecifierIsEmpty (const CXXBaseSpecifier *b)
 {
-    return ClangASTContext::RecordHasFields(cast<CXXRecordDecl>(b->getType()->getAs<RecordType>()->getDecl())) == false;
+    return ClangASTContext::RecordHasFields(b->getType()->getAsCXXRecordDecl()) == false;
 }
 
 static uint32_t
@@ -2734,7 +2942,7 @@
 size_t
 ClangASTContext::GetIndexOfChildMemberWithName
 (
-    ASTContext *ast_context,
+    ASTContext *ast,
     clang_type_t clang_type,
     const char *name,
     bool omit_empty_base_classes,
@@ -2748,6 +2956,7 @@
         switch (type_class)
         {
         case clang::Type::Record:
+            if (ClangASTContext::GetCompleteType (ast, clang_type))
             {
                 const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr());
                 const RecordDecl *record_decl = record_type->getDecl();
@@ -2780,7 +2989,7 @@
 
                     //const Decl *root_cdecl = cxx_record_decl->getCanonicalDecl();
                     // Didn't find things easily, lets let clang do its thang...
-                    IdentifierInfo & ident_ref = ast_context->Idents.get(name, name + strlen (name));
+                    IdentifierInfo & ident_ref = ast->Idents.get(name, name + strlen (name));
                     DeclarationName decl_name(&ident_ref);
 
                     CXXBasePaths paths;
@@ -2872,8 +3081,8 @@
                             // an ivar in our superclass...
                             child_indexes.push_back (0);
                             
-                            if (GetIndexOfChildMemberWithName (ast_context,
-                                                               ast_context->getObjCInterfaceType(superclass_interface_decl).getAsOpaquePtr(),
+                            if (GetIndexOfChildMemberWithName (ast,
+                                                               ast->getObjCInterfaceType(superclass_interface_decl).getAsOpaquePtr(),
                                                                name,
                                                                omit_empty_base_classes,
                                                                child_indexes))
@@ -2895,7 +3104,7 @@
             
         case clang::Type::ObjCObjectPointer:
             {
-                return GetIndexOfChildMemberWithName (ast_context,
+                return GetIndexOfChildMemberWithName (ast,
                                                       cast<ObjCObjectPointerType>(qual_type.getTypePtr())->getPointeeType().getAsOpaquePtr(),
                                                       name,
                                                       omit_empty_base_classes,
@@ -2911,7 +3120,7 @@
 //
 //                if (idx < element_count)
 //                {
-//                    std::pair<uint64_t, unsigned> field_type_info = ast_context->getTypeInfo(array->getElementType());
+//                    std::pair<uint64_t, unsigned> field_type_info = ast->getTypeInfo(array->getElementType());
 //
 //                    char element_name[32];
 //                    ::snprintf (element_name, sizeof (element_name), "%s[%u]", parent_name ? parent_name : "", idx);
@@ -2932,7 +3141,7 @@
 //
 //                if (ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
 //                {
-//                    return GetIndexOfChildWithName (ast_context,
+//                    return GetIndexOfChildWithName (ast,
 //                                                    mem_ptr_type->getPointeeType().getAsOpaquePtr(),
 //                                                    name);
 //                }
@@ -2947,7 +3156,7 @@
 
                 if (ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
                 {
-                    return GetIndexOfChildMemberWithName (ast_context,
+                    return GetIndexOfChildMemberWithName (ast,
                                                           reference_type->getPointeeType().getAsOpaquePtr(),
                                                           name,
                                                           omit_empty_base_classes,
@@ -2963,7 +3172,7 @@
 
                 if (ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
                 {
-                    return GetIndexOfChildMemberWithName (ast_context,
+                    return GetIndexOfChildMemberWithName (ast,
                                                           pointer_type->getPointeeType().getAsOpaquePtr(),
                                                           name,
                                                           omit_empty_base_classes,
@@ -2980,7 +3189,7 @@
 //                    // We have a pointer to an simple type
 //                    if (idx == 0)
 //                    {
-//                        std::pair<uint64_t, unsigned> clang_type_info = ast_context->getTypeInfo(pointee_type);
+//                        std::pair<uint64_t, unsigned> clang_type_info = ast->getTypeInfo(pointee_type);
 //                        assert(clang_type_info.first % 8 == 0);
 //                        child_byte_size = clang_type_info.first / 8;
 //                        child_byte_offset = 0;
@@ -2991,7 +3200,7 @@
             break;
 
         case clang::Type::Typedef:
-            return GetIndexOfChildMemberWithName (ast_context,
+            return GetIndexOfChildMemberWithName (ast,
                                                   cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
                                                   name,
                                                   omit_empty_base_classes,
@@ -3012,7 +3221,7 @@
 uint32_t
 ClangASTContext::GetIndexOfChildWithName
 (
-    ASTContext *ast_context,
+    ASTContext *ast,
     clang_type_t clang_type,
     const char *name,
     bool omit_empty_base_classes
@@ -3027,6 +3236,7 @@
         switch (type_class)
         {
         case clang::Type::Record:
+            if (ClangASTContext::GetCompleteType (ast, clang_type))
             {
                 const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr());
                 const RecordDecl *record_decl = record_type->getDecl();
@@ -3110,7 +3320,7 @@
             
         case clang::Type::ObjCObjectPointer:
             {
-                return GetIndexOfChildWithName (ast_context,
+                return GetIndexOfChildWithName (ast,
                                                 cast<ObjCObjectPointerType>(qual_type.getTypePtr())->getPointeeType().getAsOpaquePtr(),
                                                 name,
                                                 omit_empty_base_classes);
@@ -3124,7 +3334,7 @@
 //
 //                if (idx < element_count)
 //                {
-//                    std::pair<uint64_t, unsigned> field_type_info = ast_context->getTypeInfo(array->getElementType());
+//                    std::pair<uint64_t, unsigned> field_type_info = ast->getTypeInfo(array->getElementType());
 //
 //                    char element_name[32];
 //                    ::snprintf (element_name, sizeof (element_name), "%s[%u]", parent_name ? parent_name : "", idx);
@@ -3145,7 +3355,7 @@
 //
 //                if (ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
 //                {
-//                    return GetIndexOfChildWithName (ast_context,
+//                    return GetIndexOfChildWithName (ast,
 //                                                    mem_ptr_type->getPointeeType().getAsOpaquePtr(),
 //                                                    name);
 //                }
@@ -3160,7 +3370,7 @@
 
                 if (ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
                 {
-                    return GetIndexOfChildWithName (ast_context,
+                    return GetIndexOfChildWithName (ast,
                                                     reference_type->getPointeeType().getAsOpaquePtr(),
                                                     name,
                                                     omit_empty_base_classes);
@@ -3175,7 +3385,7 @@
 
                 if (ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
                 {
-                    return GetIndexOfChildWithName (ast_context,
+                    return GetIndexOfChildWithName (ast,
                                                     pointer_type->getPointeeType().getAsOpaquePtr(),
                                                     name,
                                                     omit_empty_base_classes);
@@ -3191,7 +3401,7 @@
 //                    // We have a pointer to an simple type
 //                    if (idx == 0)
 //                    {
-//                        std::pair<uint64_t, unsigned> clang_type_info = ast_context->getTypeInfo(pointee_type);
+//                        std::pair<uint64_t, unsigned> clang_type_info = ast->getTypeInfo(pointee_type);
 //                        assert(clang_type_info.first % 8 == 0);
 //                        child_byte_size = clang_type_info.first / 8;
 //                        child_byte_offset = 0;
@@ -3202,7 +3412,7 @@
             break;
 
         case clang::Type::Typedef:
-            return GetIndexOfChildWithName (ast_context,
+            return GetIndexOfChildWithName (ast,
                                             cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
                                             name,
                                             omit_empty_base_classes);
@@ -3293,10 +3503,10 @@
     // like maybe filling in the SourceLocation with it...
     if (name)
     {
-        ASTContext *ast_context = getASTContext();
+        ASTContext *ast = getASTContext();
         if (decl_ctx == NULL)
-            decl_ctx = ast_context->getTranslationUnitDecl();
-        return NamespaceDecl::Create(*ast_context, decl_ctx, SourceLocation(), &ast_context->Idents.get(name));
+            decl_ctx = ast->getTranslationUnitDecl();
+        return NamespaceDecl::Create(*ast, decl_ctx, SourceLocation(), &ast->Idents.get(name));
     }
     return NULL;
 }
@@ -3309,15 +3519,15 @@
 {
     if (name)
     {
-        ASTContext *ast_context = getASTContext();
-        assert (ast_context != NULL);
+        ASTContext *ast = getASTContext();
+        assert (ast != NULL);
 
         if (name && name[0])
         {
-            return FunctionDecl::Create(*ast_context,
-                                        ast_context->getTranslationUnitDecl(),
+            return FunctionDecl::Create(*ast,
+                                        ast->getTranslationUnitDecl(),
                                         SourceLocation(),
-                                        DeclarationName (&ast_context->Idents.get(name)),
+                                        DeclarationName (&ast->Idents.get(name)),
                                         QualType::getFromOpaquePtr(function_clang_type),
                                         NULL,
                                         (FunctionDecl::StorageClass)storage,
@@ -3326,8 +3536,8 @@
         }
         else
         {
-            return FunctionDecl::Create(*ast_context,
-                                        ast_context->getTranslationUnitDecl(),
+            return FunctionDecl::Create(*ast,
+                                        ast->getTranslationUnitDecl(),
                                         SourceLocation(),
                                         DeclarationName (),
                                         QualType::getFromOpaquePtr(function_clang_type),
@@ -3341,20 +3551,20 @@
 }
 
 clang_type_t
-ClangASTContext::CreateFunctionType (ASTContext *ast_context,
+ClangASTContext::CreateFunctionType (ASTContext *ast,
                                      clang_type_t result_type, 
                                      clang_type_t *args, 
                                      unsigned num_args, 
                                      bool is_variadic, 
                                      unsigned type_quals)
 {
-    assert (ast_context != NULL);
+    assert (ast != NULL);
     std::vector<QualType> qual_type_args;
     for (unsigned i=0; i<num_args; ++i)
         qual_type_args.push_back (QualType::getFromOpaquePtr(args[i]));
 
     // TODO: Detect calling convention in DWARF?
-    return ast_context->getFunctionType(QualType::getFromOpaquePtr(result_type),
+    return ast->getFunctionType(QualType::getFromOpaquePtr(result_type),
                                         qual_type_args.empty() ? NULL : &qual_type_args.front(),
                                         qual_type_args.size(),
                                         is_variadic,
@@ -3369,12 +3579,12 @@
 ParmVarDecl *
 ClangASTContext::CreateParameterDeclaration (const char *name, clang_type_t param_type, int storage)
 {
-    ASTContext *ast_context = getASTContext();
-    assert (ast_context != NULL);
-    return ParmVarDecl::Create(*ast_context,
-                                ast_context->getTranslationUnitDecl(),
+    ASTContext *ast = getASTContext();
+    assert (ast != NULL);
+    return ParmVarDecl::Create(*ast,
+                                ast->getTranslationUnitDecl(),
                                 SourceLocation(),
-                                name && name[0] ? &ast_context->Idents.get(name) : NULL,
+                                name && name[0] ? &ast->Idents.get(name) : NULL,
                                 QualType::getFromOpaquePtr(param_type),
                                 NULL,
                                 (VarDecl::StorageClass)storage,
@@ -3397,10 +3607,10 @@
 {
     if (element_type)
     {
-        ASTContext *ast_context = getASTContext();
-        assert (ast_context != NULL);
+        ASTContext *ast = getASTContext();
+        assert (ast != NULL);
         llvm::APInt ap_element_count (64, element_count);
-        return ast_context->getConstantArrayType(QualType::getFromOpaquePtr(element_type),
+        return ast->getConstantArrayType(QualType::getFromOpaquePtr(element_type),
                                                  ap_element_count,
                                                  ArrayType::Normal,
                                                  0).getAsOpaquePtr(); // ElemQuals
@@ -3473,17 +3683,17 @@
                 unsigned NumPositiveBits = 1;
                 unsigned NumNegativeBits = 0;
                 
-                ASTContext *ast_context = getASTContext();
+                ASTContext *ast = getASTContext();
 
                 QualType promotion_qual_type;
                 // If the enum integer type is less than an integer in bit width,
                 // then we must promote it to an integer size.
-                if (ast_context->getTypeSize(enum_decl->getIntegerType()) < ast_context->getTypeSize(ast_context->IntTy))
+                if (ast->getTypeSize(enum_decl->getIntegerType()) < ast->getTypeSize(ast->IntTy))
                 {
                     if (enum_decl->getIntegerType()->isSignedIntegerType())
-                        promotion_qual_type = ast_context->IntTy;
+                        promotion_qual_type = ast->IntTy;
                     else
-                        promotion_qual_type = ast_context->UnsignedIntTy;
+                        promotion_qual_type = ast->UnsignedIntTy;
                 }
                 else
                     promotion_qual_type = enum_decl->getIntegerType();
@@ -3510,17 +3720,17 @@
 {
     // TODO: Do something intelligent with the Declaration object passed in
     // like maybe filling in the SourceLocation with it...
-    ASTContext *ast_context = getASTContext();
-    assert (ast_context != NULL);
+    ASTContext *ast = getASTContext();
+    assert (ast != NULL);
 
     // TODO: ask about these...
 //    const bool IsScoped = false;
 //    const bool IsFixed = false;
 
-    EnumDecl *enum_decl = EnumDecl::Create (*ast_context,
+    EnumDecl *enum_decl = EnumDecl::Create (*ast,
                                             decl_ctx,
                                             SourceLocation(),
-                                            name && name[0] ? &ast_context->Idents.get(name) : NULL,
+                                            name && name[0] ? &ast->Idents.get(name) : NULL,
                                             SourceLocation(),
                                             NULL, 
                                             false,  // IsScoped
@@ -3530,7 +3740,7 @@
     {
         // TODO: check if we should be setting the promotion type too?
         enum_decl->setIntegerType(QualType::getFromOpaquePtr (integer_qual_type));
-        return ast_context->getTagDeclType(enum_decl).getAsOpaquePtr();
+        return ast->getTagDeclType(enum_decl).getAsOpaquePtr();
     }
     return NULL;
 }
@@ -3568,10 +3778,10 @@
     {
         // TODO: Do something intelligent with the Declaration object passed in
         // like maybe filling in the SourceLocation with it...
-        ASTContext *ast_context = getASTContext();
+        ASTContext *ast = getASTContext();
         IdentifierTable *identifier_table = getIdentifierTable();
 
-        assert (ast_context != NULL);
+        assert (ast != NULL);
         assert (identifier_table != NULL);
         QualType enum_qual_type (QualType::getFromOpaquePtr(enum_clang_type));
 
@@ -3585,14 +3795,14 @@
                 llvm::APSInt enum_llvm_apsint(enum_value_bit_size, false);
                 enum_llvm_apsint = enum_value;
                 EnumConstantDecl *enumerator_decl =
-                    EnumConstantDecl::Create(*ast_context,
-                                             enum_type->getDecl(),
-                                             SourceLocation(),
-                                             name ? &identifier_table->get(name) : NULL,    // Identifier
-                                             QualType::getFromOpaquePtr(enumerator_clang_type),
-                                             NULL,
-                                             enum_llvm_apsint);
-
+                    EnumConstantDecl::Create (*ast,
+                                              enum_type->getDecl(),
+                                              SourceLocation(),
+                                              name ? &identifier_table->get(name) : NULL,    // Identifier
+                                              QualType::getFromOpaquePtr(enumerator_clang_type),
+                                              NULL,
+                                              enum_llvm_apsint);
+                
                 if (enumerator_decl)
                 {
                     enum_type->getDecl()->addDecl(enumerator_decl);
@@ -3663,8 +3873,8 @@
 size_t
 ClangASTContext::GetPointerBitSize ()
 {
-    ASTContext *ast_context = getASTContext();
-    return ast_context->getTypeSize(ast_context->VoidPtrTy);
+    ASTContext *ast = getASTContext();
+    return ast->getTypeSize(ast->VoidPtrTy);
 }
 
 bool
@@ -3997,20 +4207,20 @@
     if (clang_type)
     {
         QualType qual_type (QualType::getFromOpaquePtr(clang_type));
-        ASTContext *ast_context = getASTContext();
+        ASTContext *ast = getASTContext();
         IdentifierTable *identifier_table = getIdentifierTable();
-        assert (ast_context != NULL);
+        assert (ast != NULL);
         assert (identifier_table != NULL);
         if (decl_ctx == NULL)
-            decl_ctx = ast_context->getTranslationUnitDecl();
-        TypedefDecl *decl = TypedefDecl::Create(*ast_context,
-                                                decl_ctx,
-                                                SourceLocation(),
-                                                name ? &identifier_table->get(name) : NULL, // Identifier
-                                                ast_context->CreateTypeSourceInfo(qual_type));
+            decl_ctx = ast->getTranslationUnitDecl();
+        TypedefDecl *decl = TypedefDecl::Create (*ast,
+                                                 decl_ctx,
+                                                 SourceLocation(),
+                                                 name ? &identifier_table->get(name) : NULL, // Identifier
+                                                 ast->CreateTypeSourceInfo(qual_type));
 
         // Get a uniqued QualType for the typedef decl type
-        return ast_context->getTypedefType (decl).getAsOpaquePtr();
+        return ast->getTypedefType (decl).getAsOpaquePtr();
     }
     return NULL;
 }
@@ -4044,7 +4254,7 @@
 // so we can support remote targets. The code below also requires a patch to
 // llvm::APInt.
 //bool
-//ClangASTContext::ConvertFloatValueToString (ASTContext *ast_context, clang_type_t clang_type, const uint8_t* bytes, size_t byte_size, int apint_byte_order, std::string &float_str)
+//ClangASTContext::ConvertFloatValueToString (ASTContext *ast, clang_type_t clang_type, const uint8_t* bytes, size_t byte_size, int apint_byte_order, std::string &float_str)
 //{
 //  uint32_t count = 0;
 //  bool is_complex = false;
@@ -4079,7 +4289,7 @@
 //}
 
 size_t
-ClangASTContext::ConvertStringToFloatValue (ASTContext *ast_context, clang_type_t clang_type, const char *s, uint8_t *dst, size_t dst_size)
+ClangASTContext::ConvertStringToFloatValue (ASTContext *ast, clang_type_t clang_type, const char *s, uint8_t *dst, size_t dst_size)
 {
     if (clang_type)
     {
@@ -4093,9 +4303,9 @@
                 return false;
 
             StringRef s_sref(s);
-            APFloat ap_float(ast_context->getFloatTypeSemantics(qual_type), s_sref);
+            APFloat ap_float(ast->getFloatTypeSemantics(qual_type), s_sref);
 
-            const uint64_t bit_size = ast_context->getTypeSize (qual_type);
+            const uint64_t bit_size = ast->getTypeSize (qual_type);
             const uint64_t byte_size = bit_size / 8;
             if (dst_size >= byte_size)
             {
@@ -4126,3 +4336,21 @@
     
     return qual_type.getQualifiers().getCVRQualifiers();
 }
+
+bool
+ClangASTContext::GetCompleteType (clang::ASTContext *ast, lldb::clang_type_t clang_type)
+{
+    if (clang_type == NULL)
+        return false;
+
+    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
+    return GetCompleteQualType (ast, qual_type);
+}
+
+
+bool
+ClangASTContext::GetCompleteType (clang_type_t clang_type)
+{   
+    return ClangASTContext::GetCompleteType (getASTContext(), clang_type);
+}
+

Modified: lldb/trunk/source/Symbol/ClangASTType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTType.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTType.cpp Sun Jan 16 21:46:26 2011
@@ -363,6 +363,7 @@
     switch (qual_type->getTypeClass())
     {
     case clang::Type::Record:
+        if (ClangASTContext::GetCompleteType (ast_context, clang_type))
         {
             const clang::RecordType *record_type = cast<clang::RecordType>(qual_type.getTypePtr());
             const clang::RecordDecl *record_decl = record_type->getDecl();
@@ -491,6 +492,7 @@
         return;
 
     case clang::Type::Enum:
+        if (ClangASTContext::GetCompleteType (ast_context, clang_type))
         {
             const clang::EnumType *enum_type = cast<clang::EnumType>(qual_type.getTypePtr());
             const clang::EnumDecl *enum_decl = enum_type->getDecl();
@@ -690,7 +692,7 @@
         case clang::Type::Enum:
             // If our format is enum or default, show the enumeration value as
             // its enumeration string value, else just display it as requested.
-            if (format == eFormatEnum || format == eFormatDefault)
+            if ((format == eFormatEnum || format == eFormatDefault) && ClangASTContext::GetCompleteType (ast_context, clang_type))
             {
                 const clang::EnumType *enum_type = cast<clang::EnumType>(qual_type.getTypePtr());
                 const clang::EnumDecl *enum_decl = enum_type->getDecl();

Modified: lldb/trunk/source/Symbol/SymbolFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolFile.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolFile.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolFile.cpp Sun Jan 16 21:46:26 2011
@@ -18,7 +18,7 @@
 SymbolFile*
 SymbolFile::FindPlugin (ObjectFile* obj_file)
 {
-    std::auto_ptr<SymbolFile> best_sym_file_ap;
+    std::auto_ptr<SymbolFile> best_symfile_ap;
     if (obj_file != NULL)
     {
         // TODO: Load any plug-ins in the appropriate plug-in search paths and
@@ -27,7 +27,6 @@
         //----------------------------------------------------------------------
         // We currently only have one debug symbol parser...
         //----------------------------------------------------------------------
-        std::auto_ptr<SymbolFile> best_symfile_ap;
         uint32_t best_symfile_abilities = 0;
 
         SymbolFileCreateInstance create_callback;
@@ -41,16 +40,31 @@
                 if (sym_file_abilities > best_symfile_abilities)
                 {
                     best_symfile_abilities = sym_file_abilities;
-                    best_sym_file_ap = curr_symfile_ap;
+                    best_symfile_ap = curr_symfile_ap;
                 }
             }
         }
+        if (best_symfile_ap.get())
+        {
+            // Let the winning symbol file parser initialize itself more 
+            // completely now that it has been chosen
+            best_symfile_ap->InitializeObject();
+        }
     }
-    return best_sym_file_ap.release();
+    return best_symfile_ap.release();
 }
 
 TypeList *
 SymbolFile::GetTypeList ()
 {
-    return m_obj_file->GetModule()->GetTypeList();
+    if (m_obj_file)
+        return m_obj_file->GetModule()->GetTypeList();
+    return NULL;
+}
+
+lldb_private::ClangASTContext &       
+SymbolFile::GetClangASTContext ()
+{
+    return m_obj_file->GetModule()->GetClangASTContext();
 }
+

Modified: lldb/trunk/source/Symbol/SymbolVendor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolVendor.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolVendor.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolVendor.cpp Sun Jan 16 21:46:26 2011
@@ -69,12 +69,6 @@
     m_compile_units(),
     m_sym_file_ap()
 {
-    ObjectFile * objfile = module->GetObjectFile();
-    ConstString target_triple;
-    if (objfile && objfile->GetTargetTriple(target_triple))
-    {
-        m_type_list.GetClangASTContext().SetTargetTriple (target_triple.AsCString());
-    }
 }
 
 //----------------------------------------------------------------------

Modified: lldb/trunk/source/Symbol/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Type.cpp (original)
+++ lldb/trunk/source/Symbol/Type.cpp Sun Jan 16 21:46:26 2011
@@ -284,7 +284,7 @@
         case eEncodingIsPointerUID:
         case eEncodingIsLValueReferenceUID:
         case eEncodingIsRValueReferenceUID:
-            m_byte_size = GetTypeList()->GetClangASTContext().GetPointerBitSize() / 8;
+            m_byte_size = m_symbol_file->GetClangASTContext().GetPointerBitSize() / 8;
             break;
         }
     }
@@ -295,10 +295,13 @@
 uint32_t
 lldb_private::Type::GetNumChildren (bool omit_empty_base_classes)
 {
-    if (!ResolveClangType(eResolveStateFull))
-        return 0;
-    return ClangASTContext::GetNumChildren (m_clang_type, omit_empty_base_classes);
-
+    if (ResolveClangType(eResolveStateForward))
+    {
+        return ClangASTContext::GetNumChildren (m_symbol_file->GetClangASTContext().getASTContext(),
+                                                m_clang_type, 
+                                                omit_empty_base_classes);
+    }
+    return 0;
 }
 
 bool
@@ -422,7 +425,6 @@
     Type *encoding_type = NULL;
     if (m_clang_type == NULL)
     {
-        TypeList *type_list = GetTypeList();
         encoding_type = GetEncodingType();
         if (encoding_type)
         {
@@ -449,22 +451,22 @@
                 break;
 
             case eEncodingIsTypedefUID:
-                m_clang_type = type_list->CreateClangTypedefType (this, encoding_type);
+                m_clang_type = CreateClangTypedefType (this, encoding_type);
                 // Clear the name so it can get fully qualified in case the
                 // typedef is in a namespace.
                 m_name.Clear();
                 break;
 
             case eEncodingIsPointerUID:
-                m_clang_type = type_list->CreateClangPointerType (encoding_type);
+                m_clang_type = CreateClangPointerType (encoding_type);
                 break;
 
             case eEncodingIsLValueReferenceUID:
-                m_clang_type = type_list->CreateClangLValueReferenceType (encoding_type);
+                m_clang_type = CreateClangLValueReferenceType (encoding_type);
                 break;
 
             case eEncodingIsRValueReferenceUID:
-                m_clang_type = type_list->CreateClangRValueReferenceType (encoding_type);
+                m_clang_type = CreateClangRValueReferenceType (encoding_type);
                 break;
 
             default:
@@ -475,7 +477,7 @@
         else
         {
             // We have no encoding type, return void?
-            clang_type_t void_clang_type = type_list->GetClangASTContext().GetBuiltInType_void();
+            clang_type_t void_clang_type = GetClangASTContext().GetBuiltInType_void();
             switch (m_encoding_uid_type)
             {
             case eEncodingIsUID:
@@ -495,19 +497,19 @@
                 break;
 
             case eEncodingIsTypedefUID:
-                m_clang_type = type_list->GetClangASTContext().CreateTypedefType (m_name.AsCString(), void_clang_type, NULL);
+                m_clang_type = GetClangASTContext().CreateTypedefType (m_name.AsCString(), void_clang_type, NULL);
                 break;
 
             case eEncodingIsPointerUID:
-                m_clang_type = type_list->GetClangASTContext().CreatePointerType (void_clang_type);
+                m_clang_type = GetClangASTContext().CreatePointerType (void_clang_type);
                 break;
 
             case eEncodingIsLValueReferenceUID:
-                m_clang_type = type_list->GetClangASTContext().CreateLValueReferenceType (void_clang_type);
+                m_clang_type = GetClangASTContext().CreateLValueReferenceType (void_clang_type);
                 break;
 
             case eEncodingIsRValueReferenceUID:
-                m_clang_type = type_list->GetClangASTContext().CreateRValueReferenceType (void_clang_type);
+                m_clang_type = GetClangASTContext().CreateRValueReferenceType (void_clang_type);
                 break;
 
             default:
@@ -636,16 +638,13 @@
 clang::ASTContext *
 lldb_private::Type::GetClangAST ()
 {
-    TypeList *type_list = GetTypeList();
-    if (type_list)
-        return type_list->GetClangASTContext().getASTContext();
-    return NULL;
+    return GetClangASTContext().getASTContext();
 }
 
 lldb_private::ClangASTContext &
 lldb_private::Type::GetClangASTContext ()
 {
-    return GetTypeList()->GetClangASTContext();
+    return m_symbol_file->GetClangASTContext();
 }
 
 int
@@ -663,3 +662,35 @@
 //      return 0;
 }
 
+
+void *
+lldb_private::Type::CreateClangPointerType (lldb_private::Type *type)
+{
+    assert(type);
+    return GetClangASTContext().CreatePointerType(type->GetClangForwardType());
+}
+
+void *
+lldb_private::Type::CreateClangTypedefType (lldb_private::Type *typedef_type, lldb_private::Type *base_type)
+{
+    assert(typedef_type && base_type);
+    return GetClangASTContext().CreateTypedefType (typedef_type->GetName().AsCString(), 
+                                                   base_type->GetClangForwardType(), 
+                                                   typedef_type->GetSymbolFile()->GetClangDeclContextForTypeUID(typedef_type->GetID()));
+}
+
+void *
+lldb_private::Type::CreateClangLValueReferenceType (lldb_private::Type *type)
+{
+    assert(type);
+    return GetClangASTContext().CreateLValueReferenceType(type->GetClangForwardType());
+}
+
+void *
+lldb_private::Type::CreateClangRValueReferenceType (lldb_private::Type *type)
+{
+    assert(type);
+    return GetClangASTContext().CreateRValueReferenceType (type->GetClangForwardType());
+}
+
+

Modified: lldb/trunk/source/Symbol/TypeList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/TypeList.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/TypeList.cpp (original)
+++ lldb/trunk/source/Symbol/TypeList.cpp Sun Jan 16 21:46:26 2011
@@ -29,7 +29,6 @@
 #include "llvm/Support/raw_ostream.h"
 
 // Project includes
-#include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Symbol/SymbolVendor.h"
 #include "lldb/Symbol/Type.h"
@@ -39,8 +38,7 @@
 using namespace lldb_private;
 using namespace clang;
 
-TypeList::TypeList(const char *target_triple) :
-    m_ast (target_triple),
+TypeList::TypeList() :
     m_types ()
 {
 }
@@ -94,18 +92,18 @@
 //----------------------------------------------------------------------
 // Find a type by name.
 //----------------------------------------------------------------------
-TypeList
-TypeList::FindTypes (const ConstString &name)
-{
-    // Do we ever need to make a lookup by name map? Here we are doing
-    // a linear search which isn't going to be fast.
-    TypeList types(m_ast.getTargetInfo()->getTriple().getTriple().c_str());
-    iterator pos, end;
-    for (pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
-        if (pos->second->GetName() == name)
-            types.Insert (pos->second);
-    return types;
-}
+//TypeList
+//TypeList::FindTypes (const ConstString &name)
+//{
+//    // Do we ever need to make a lookup by name map? Here we are doing
+//    // a linear search which isn't going to be fast.
+//    TypeList types(m_ast.getTargetInfo()->getTriple().getTriple().c_str());
+//    iterator pos, end;
+//    for (pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
+//        if (pos->second->GetName() == name)
+//            types.Insert (pos->second);
+//    return types;
+//}
 
 void
 TypeList::Clear()
@@ -146,42 +144,35 @@
     }
 }
 
-
-ClangASTContext &
-TypeList::GetClangASTContext ()
-{
-    return m_ast;
-}
-
-void *
-TypeList::CreateClangPointerType (Type *type)
-{
-    assert(type);
-    return m_ast.CreatePointerType(type->GetClangForwardType());
-}
-
-void *
-TypeList::CreateClangTypedefType (Type *typedef_type, Type *base_type)
-{
-    assert(typedef_type && base_type);
-    return m_ast.CreateTypedefType (typedef_type->GetName().AsCString(), 
-                                    base_type->GetClangForwardType(), 
-                                    typedef_type->GetSymbolFile()->GetClangDeclContextForTypeUID(typedef_type->GetID()));
-}
-
-void *
-TypeList::CreateClangLValueReferenceType (Type *type)
-{
-    assert(type);
-    return m_ast.CreateLValueReferenceType(type->GetClangForwardType());
-}
-
-void *
-TypeList::CreateClangRValueReferenceType (Type *type)
-{
-    assert(type);
-    return m_ast.CreateRValueReferenceType (type->GetClangForwardType());
-}
-
+//void *
+//TypeList::CreateClangPointerType (Type *type)
+//{
+//    assert(type);
+//    return m_ast.CreatePointerType(type->GetClangForwardType());
+//}
+//
+//void *
+//TypeList::CreateClangTypedefType (Type *typedef_type, Type *base_type)
+//{
+//    assert(typedef_type && base_type);
+//    return m_ast.CreateTypedefType (typedef_type->GetName().AsCString(), 
+//                                    base_type->GetClangForwardType(), 
+//                                    typedef_type->GetSymbolFile()->GetClangDeclContextForTypeUID(typedef_type->GetID()));
+//}
+//
+//void *
+//TypeList::CreateClangLValueReferenceType (Type *type)
+//{
+//    assert(type);
+//    return m_ast.CreateLValueReferenceType(type->GetClangForwardType());
+//}
+//
+//void *
+//TypeList::CreateClangRValueReferenceType (Type *type)
+//{
+//    assert(type);
+//    return m_ast.CreateRValueReferenceType (type->GetClangForwardType());
+//}
+//
 
 

Modified: lldb/trunk/source/Target/StackFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrame.cpp (original)
+++ lldb/trunk/source/Target/StackFrame.cpp Sun Jan 16 21:46:26 2011
@@ -562,7 +562,7 @@
                                 {
                                     // Incorrect use of "." with a pointer, or "->" with
                                     // a class/union/struct instance or reference.
-                                    valobj_sp->GetExpressionPath (var_expr_path_strm);
+                                    valobj_sp->GetExpressionPath (var_expr_path_strm, false);
                                     if (actual_is_ptr)
                                         error.SetErrorStringWithFormat ("\"%s\" is a pointer and . was used to attempt to access \"%s\". Did you mean \"%s->%s\"?", 
                                                                         var_expr_path_strm.GetString().c_str(), 
@@ -583,7 +583,7 @@
                             if (!child_valobj_sp)
                             {
                                 // No child member with name "child_name"
-                                valobj_sp->GetExpressionPath (var_expr_path_strm);
+                                valobj_sp->GetExpressionPath (var_expr_path_strm, false);
                                 if (child_name)
                                 {
                                     error.SetErrorStringWithFormat ("\"%s\" is not a member of \"(%s) %s\"", 
@@ -619,7 +619,7 @@
                                     child_valobj_sp = valobj_sp->GetSyntheticArrayMemberFromPointer (child_index, true);
                                     if (!child_valobj_sp)
                                     {
-                                        valobj_sp->GetExpressionPath (var_expr_path_strm);
+                                        valobj_sp->GetExpressionPath (var_expr_path_strm, false);
                                         error.SetErrorStringWithFormat ("failed to use pointer as array for index %i for \"(%s) %s\"", 
                                                                         child_index, 
                                                                         valobj_sp->GetTypeName().AsCString("<invalid type>"),
@@ -631,7 +631,7 @@
                                     child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true);
                                     if (!child_valobj_sp)
                                     {
-                                        valobj_sp->GetExpressionPath (var_expr_path_strm);
+                                        valobj_sp->GetExpressionPath (var_expr_path_strm, false);
                                         error.SetErrorStringWithFormat ("array index %i is not valid for \"(%s) %s\"", 
                                                                         child_index, 
                                                                         valobj_sp->GetTypeName().AsCString("<invalid type>"),
@@ -640,7 +640,7 @@
                                 }
                                 else
                                 {
-                                    valobj_sp->GetExpressionPath (var_expr_path_strm);
+                                    valobj_sp->GetExpressionPath (var_expr_path_strm, false);
                                     error.SetErrorStringWithFormat ("\"(%s) %s\" is not an array type", 
                                                                     valobj_sp->GetTypeName().AsCString("<invalid type>"),
                                                                     var_expr_path_strm.GetString().c_str());
@@ -667,7 +667,7 @@
                     default:
                         // Failure...
                         {
-                            valobj_sp->GetExpressionPath (var_expr_path_strm);
+                            valobj_sp->GetExpressionPath (var_expr_path_strm, false);
                             error.SetErrorStringWithFormat ("unexpected char '%c' encountered after \"%s\" in \"%s\"", 
                                                             separator_type,
                                                             var_expr_path_strm.GetString().c_str(),

Modified: lldb/trunk/source/Target/ThreadPlanTracer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTracer.cpp?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanTracer.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanTracer.cpp Sun Jan 16 21:46:26 2011
@@ -114,13 +114,12 @@
     
     m_abi = process.GetABI();
     
-    ModuleSP executableModuleSP (target.GetExecutableModule());
-    TypeList *type_list = executableModuleSP->GetTypeList();
+    ModuleSP exe_module_sp (target.GetExecutableModule());
     
-    if (type_list)
+    if (exe_module_sp)
     {
-        m_intptr_type = TypeFromUser(type_list->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, arch.GetAddressByteSize() * 8),
-                                     type_list->GetClangASTContext().getASTContext());
+        m_intptr_type = TypeFromUser(exe_module_sp->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, arch.GetAddressByteSize() * 8),
+                                     exe_module_sp->GetClangASTContext().getASTContext());
     }
     
     const unsigned int buf_size = 32;

Modified: lldb/trunk/test/class_types/TestClassTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=123613&r1=123612&r2=123613&view=diff
==============================================================================
--- lldb/trunk/test/class_types/TestClassTypes.py (original)
+++ lldb/trunk/test/class_types/TestClassTypes.py Sun Jan 16 21:46:26 2011
@@ -180,7 +180,7 @@
 
         # Verify that 'frame variable this' gets the data type correct.
         self.expect("frame variable this",VARIABLES_DISPLAYED_CORRECTLY,
-            substrs = ['class C *'])
+            substrs = ['C *'])
 
         # Verify that frame variable -t this->m_c_int behaves correctly.
         self.expect("frame variable -t this->m_c_int", VARIABLES_DISPLAYED_CORRECTLY,
@@ -188,7 +188,7 @@
 
         # Verify that 'expression this' gets the data type correct.
         self.expect("expression this", VARIABLES_DISPLAYED_CORRECTLY,
-            substrs = ['class C *'])
+            substrs = ['C *'])
 
         # rdar://problem/8430916
         # expr this->m_c_int returns an incorrect value





More information about the lldb-commits mailing list