[Lldb-commits] [lldb] r110174 - in /lldb/trunk: include/lldb/Expression/ClangASTSource.h include/lldb/Expression/ClangExpressionDeclMap.h include/lldb/Symbol/SymbolContext.h source/Expression/ClangASTSource.cpp source/Expression/ClangExpression.cpp source/Expression/ClangExpressionDeclMap.cpp source/Expression/IRForTarget.cpp source/Symbol/SymbolContext.cpp

Sean Callanan scallanan at apple.com
Tue Aug 3 18:02:13 PDT 2010


Author: spyffe
Date: Tue Aug  3 20:02:13 2010
New Revision: 110174

URL: http://llvm.org/viewvc/llvm-project?rev=110174&view=rev
Log:
Added support for accessing members of C++ objects,
including superclass members.  This involved ensuring
that access control was ignored, and ensuring that
the operands of BitCasts were properly scanned for
variables that needed importing.

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

Modified:
    lldb/trunk/include/lldb/Expression/ClangASTSource.h
    lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
    lldb/trunk/include/lldb/Symbol/SymbolContext.h
    lldb/trunk/source/Expression/ClangASTSource.cpp
    lldb/trunk/source/Expression/ClangExpression.cpp
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
    lldb/trunk/source/Expression/IRForTarget.cpp
    lldb/trunk/source/Symbol/SymbolContext.cpp

Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangASTSource.h?rev=110174&r1=110173&r2=110174&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangASTSource.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangASTSource.h Tue Aug  3 20:02:13 2010
@@ -62,6 +62,7 @@
     clang::NamedDecl *AddVarDecl(void *type);
     clang::NamedDecl *AddFunDecl(void *type);
     clang::NamedDecl *AddGenericFunDecl();
+    clang::NamedDecl *AddTypeDecl(void *type);
 };
 
 }

Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=110174&r1=110173&r2=110174&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Tue Aug  3 20:02:13 2010
@@ -24,6 +24,7 @@
 #include "lldb/Symbol/TaggedASTType.h"
 
 namespace llvm {
+    class Type;
     class Value;
 }
 
@@ -139,6 +140,7 @@
     
     void AddOneVariable(NameSearchContext &context, Variable *var);
     void AddOneFunction(NameSearchContext &context, Function *fun, Symbol *sym);
+    void AddOneType(NameSearchContext &context, Type *type);
     
     bool DoMaterialize (bool dematerialize,
                         ExecutionContext *exe_ctx,

Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolContext.h?rev=110174&r1=110173&r2=110174&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/SymbolContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolContext.h Tue Aug  3 20:02:13 2010
@@ -220,7 +220,7 @@
     ///     A shared pointer to the variable found.
     //------------------------------------------------------------------
     lldb::TypeSP
-    FindTypeByName (const char *name) const;
+    FindTypeByName (const ConstString &name) const;
 
     //------------------------------------------------------------------
     // Member variables

Modified: lldb/trunk/source/Expression/ClangASTSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=110174&r1=110173&r2=110174&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangASTSource.cpp (original)
+++ lldb/trunk/source/Expression/ClangASTSource.cpp Tue Aug  3 20:02:13 2010
@@ -162,3 +162,22 @@
 
     return AddFunDecl(generic_function_type.getAsOpaquePtr());
 }
+
+clang::NamedDecl *NameSearchContext::AddTypeDecl(void *type)
+{
+    QualType QT = QualType::getFromOpaquePtr(type);
+    clang::Type *T = QT.getTypePtr();
+
+    if (TagType *tag_type = dyn_cast<clang::TagType>(T))
+    {
+        TagDecl *tag_decl = tag_type->getDecl();
+        
+        Decls.push_back(tag_decl);
+        
+        return tag_decl;
+    }
+    else
+    {
+        return NULL;
+    }
+}

Modified: lldb/trunk/source/Expression/ClangExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpression.cpp?rev=110174&r1=110173&r2=110174&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpression.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpression.cpp Tue Aug  3 20:02:13 2010
@@ -238,6 +238,7 @@
     m_clang_ap->getLangOpts().CPlusPlus = true;
     m_clang_ap->getLangOpts().ObjC1 = true;
     m_clang_ap->getLangOpts().ThreadsafeStatics = false;
+    m_clang_ap->getLangOpts().AccessControl = false; // Debuggers get universal access
     
     // Set CodeGen options
     m_clang_ap->getCodeGenOpts().EmitDeclMetadata = true;

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=110174&r1=110173&r2=110174&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Aug  3 20:02:13 2010
@@ -679,6 +679,13 @@
     
     if (var)
         AddOneVariable(context, var);
+    
+    /* Commented out pending resolution of a loop when the TagType is imported
+    lldb::TypeSP type = m_sym_ctx->FindTypeByName(name_cs);
+    
+    if (type.get())
+        AddOneType(context, type.get());
+    */
 }
         
 Value *
@@ -886,3 +893,15 @@
     if (log)
         log->Printf("Found function %s, returned (NamedDecl)%p", context.Name.getAsString().c_str(), fun_decl);    
 }
+
+void 
+ClangExpressionDeclMap::AddOneType(NameSearchContext &context, 
+                                   Type *type)
+{
+    TypeFromUser ut(type->GetOpaqueClangQualType(),
+                    type->GetClangAST());
+    
+    void *copied_type = ClangASTContext::CopyType(context.GetASTContext(), ut.GetASTContext(), ut.GetOpaqueQualType());
+    
+    context.AddTypeDecl(copied_type);
+}

Modified: lldb/trunk/source/Expression/IRForTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=110174&r1=110173&r2=110174&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRForTarget.cpp (original)
+++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Aug  3 20:02:13 2010
@@ -249,8 +249,12 @@
 
     if (ConstantExpr *constant_expr = dyn_cast<ConstantExpr>(V))
     {
-        if (constant_expr->getOpcode() == Instruction::GetElementPtr)
+        switch (constant_expr->getOpcode())
         {
+        default:
+            break;
+        case Instruction::GetElementPtr:
+        case Instruction::BitCast:
             Value *s = constant_expr->getOperand(0);
             MaybeHandleVariable(M, s, Store);
         }

Modified: lldb/trunk/source/Symbol/SymbolContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=110174&r1=110173&r2=110174&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolContext.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolContext.cpp Tue Aug  3 20:02:13 2010
@@ -403,9 +403,18 @@
 }
 
 lldb::TypeSP
-SymbolContext::FindTypeByName (const char *name) const
+SymbolContext::FindTypeByName (const ConstString &name) const
 {
     lldb::TypeSP return_value;
+        
+    TypeList types;
+    
+    if (module_sp && module_sp->FindTypes (*this, name, false, 1, types))
+        return types.GetTypeAtIndex(0);
+    
+    if (!return_value.get() && target_sp && target_sp->GetImages().FindTypes (*this, name, false, 1, types))
+        return types.GetTypeAtIndex(0);
+    
     return return_value;
 }
 





More information about the lldb-commits mailing list