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.

llvm-svn: 110174
This commit is contained in:
Sean Callanan 2010-08-04 01:02:13 +00:00
parent 66a8759400
commit 5666b674f3
8 changed files with 58 additions and 3 deletions

View File

@ -62,6 +62,7 @@ struct NameSearchContext {
clang::NamedDecl *AddVarDecl(void *type);
clang::NamedDecl *AddFunDecl(void *type);
clang::NamedDecl *AddGenericFunDecl();
clang::NamedDecl *AddTypeDecl(void *type);
};
}

View File

@ -24,6 +24,7 @@
#include "lldb/Symbol/TaggedASTType.h"
namespace llvm {
class Type;
class Value;
}
@ -139,6 +140,7 @@ private:
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,

View File

@ -220,7 +220,7 @@ public:
/// A shared pointer to the variable found.
//------------------------------------------------------------------
lldb::TypeSP
FindTypeByName (const char *name) const;
FindTypeByName (const ConstString &name) const;
//------------------------------------------------------------------
// Member variables

View File

@ -162,3 +162,22 @@ clang::NamedDecl *NameSearchContext::AddGenericFunDecl()
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;
}
}

View File

@ -238,6 +238,7 @@ ClangExpression::CreateCompilerInstance (bool &IsAST)
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;

View File

@ -679,6 +679,13 @@ ClangExpressionDeclMap::GetDecls(NameSearchContext &context,
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 @@ ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
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);
}

View File

@ -249,8 +249,12 @@ IRForTarget::MaybeHandleVariable(Module &M,
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);
}

View File

@ -403,9 +403,18 @@ SymbolContext::FindVariableByName (const char *name) const
}
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;
}