summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression/ClangUserExpression.cpp
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2011-08-05 23:43:37 +0000
committerSean Callanan <scallanan@apple.com>2011-08-05 23:43:37 +0000
commit72e4940bd1765afaab46619921cfef681c990d83 (patch)
treef49f14cc3da8f89c173d4ef08e04108aafd4c10a /lldb/source/Expression/ClangUserExpression.cpp
parent1cd34b8fea60940f99b6a8ce3fd6418953887125 (diff)
downloadbcm5719-llvm-72e4940bd1765afaab46619921cfef681c990d83.tar.gz
bcm5719-llvm-72e4940bd1765afaab46619921cfef681c990d83.zip
This is an overhaul of the expression parser code
that detects what context the current expression is meant to execute in. LLDB now properly consults the method declaration in the debug information rather than trying to hunt down the "this" or "self" pointer by name, which can be misleading. Other fixes include: - LLDB now properly detects that it is inside an inlined C++ member function. - LLDB now allows access to non-const members when in const code. - The functions in SymbolFile that locate the DeclContext containing a DIE have been renamed to reflect what they actually do. I have added new functions that find the DeclContext for the DIE itself. I have also introduced testcases for C++ and Objective-C. llvm-svn: 136999
Diffstat (limited to 'lldb/source/Expression/ClangUserExpression.cpp')
-rw-r--r--lldb/source/Expression/ClangUserExpression.cpp59
1 files changed, 32 insertions, 27 deletions
diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp
index 71a528280d9..b4a704cf33c 100644
--- a/lldb/source/Expression/ClangUserExpression.cpp
+++ b/lldb/source/Expression/ClangUserExpression.cpp
@@ -37,6 +37,9 @@
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/ThreadPlanCallUserExpression.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclObjC.h"
+
using namespace lldb_private;
ClangUserExpression::ClangUserExpression (const char *expr,
@@ -68,44 +71,46 @@ ClangUserExpression::ASTTransformer (clang::ASTConsumer *passthrough)
void
ClangUserExpression::ScanContext(ExecutionContext &exe_ctx)
{
- VariableList *vars = exe_ctx.frame->GetVariableList(false);
+ if (!exe_ctx.frame)
+ return;
+
+ SymbolContext sym_ctx = exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextFunction);
- if (!vars)
+ if (!sym_ctx.function)
return;
- lldb::VariableSP this_var(vars->FindVariable(ConstString("this")));
- lldb::VariableSP self_var(vars->FindVariable(ConstString("self")));
+ clang::DeclContext *decl_context;
- if (this_var.get())
- {
- Type *this_type = this_var->GetType();
+ if (sym_ctx.block && sym_ctx.block->GetInlinedFunctionInfo())
+ decl_context = sym_ctx.block->GetClangDeclContextForInlinedFunction();
+ else
+ decl_context = sym_ctx.function->GetClangDeclContext();
- lldb::clang_type_t pointer_target_type;
+ if (!decl_context)
+ return;
- if (ClangASTContext::IsPointerType(this_type->GetClangForwardType(),
- &pointer_target_type))
+ if (clang::CXXMethodDecl *method_decl = llvm::dyn_cast<clang::CXXMethodDecl>(decl_context))
+ {
+ if (method_decl->isInstance())
{
- TypeFromUser target_ast_type(pointer_target_type, this_type->GetClangAST());
-
- if (ClangASTContext::IsCXXClassType(target_ast_type.GetOpaqueQualType()))
- {
- m_cplusplus = true;
+ m_cplusplus = true;
- if (target_ast_type.IsConst())
- m_const_object = true;
- }
+ do {
+ clang::QualType this_type = method_decl->getThisType(decl_context->getParentASTContext());
+
+ const clang::PointerType *this_pointer_type = llvm::dyn_cast<clang::PointerType>(this_type.getTypePtr());
+
+ if (!this_pointer_type)
+ break;
+
+ clang::QualType this_pointee_type = this_pointer_type->getPointeeType();
+ } while (0);
}
}
- else if (self_var.get())
+ else if (clang::ObjCMethodDecl *method_decl = llvm::dyn_cast<clang::ObjCMethodDecl>(decl_context))
{
- m_objectivec = true;
-
- Type *self_type = self_var->GetType();
-
- if (self_type->GetClangForwardType() == self_type->GetClangASTContext().GetBuiltInType_objc_id())
- {
- m_objectivec = false;
- }
+ if (method_decl->isInstanceMethod())
+ m_objectivec = true;
}
}
OpenPOWER on IntegriCloud