diff options
| author | Greg Clayton <gclayton@apple.com> | 2012-07-14 00:53:55 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2012-07-14 00:53:55 +0000 |
| commit | 685c88c5a8d86d10b0b9077a76b22815ce092f27 (patch) | |
| tree | e341c3c30fdde248b865150b22362e488e44212c /lldb/source/Symbol | |
| parent | c22e8d11929a3107c11ddf368078238cfd6a4416 (diff) | |
| download | bcm5719-llvm-685c88c5a8d86d10b0b9077a76b22815ce092f27.tar.gz bcm5719-llvm-685c88c5a8d86d10b0b9077a76b22815ce092f27.zip | |
<rdar://problem/11870357>
Allow "frame variable" to find ivars without the need for "this->" or "self->".
llvm-svn: 160211
Diffstat (limited to 'lldb/source/Symbol')
| -rw-r--r-- | lldb/source/Symbol/Block.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Symbol/ClangASTContext.cpp | 46 | ||||
| -rw-r--r-- | lldb/source/Symbol/SymbolContext.cpp | 58 | ||||
| -rw-r--r-- | lldb/source/Symbol/VariableList.cpp | 37 |
4 files changed, 141 insertions, 2 deletions
diff --git a/lldb/source/Symbol/Block.cpp b/lldb/source/Symbol/Block.cpp index 627a5d4d4ff..fef56b17bfd 100644 --- a/lldb/source/Symbol/Block.cpp +++ b/lldb/source/Symbol/Block.cpp @@ -542,7 +542,7 @@ Block::AppendVariables } clang::DeclContext * -Block::GetClangDeclContextForInlinedFunction() +Block::GetClangDeclContext() { SymbolContext sc; diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index 6f03dfdd220..54fd53c74d1 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -6330,3 +6330,49 @@ ClangASTContext::GetAsDeclContext (clang::ObjCMethodDecl *objc_method_decl) return llvm::dyn_cast<clang::DeclContext>(objc_method_decl); } + +bool +ClangASTContext::GetClassMethodInfoForDeclContext (clang::DeclContext *decl_ctx, + lldb::LanguageType &language, + bool &is_instance_method, + ConstString &language_object_name) +{ + language_object_name.Clear(); + language = eLanguageTypeUnknown; + is_instance_method = false; + + if (decl_ctx) + { + if (clang::CXXMethodDecl *method_decl = llvm::dyn_cast<clang::CXXMethodDecl>(decl_ctx)) + { + if (method_decl->isStatic()) + { + is_instance_method = false; + } + else + { + language_object_name.SetCString("this"); + is_instance_method = true; + } + language = eLanguageTypeC_plus_plus; + return true; + } + else if (clang::ObjCMethodDecl *method_decl = llvm::dyn_cast<clang::ObjCMethodDecl>(decl_ctx)) + { + // Both static and instance methods have a "self" object in objective C + language_object_name.SetCString("self"); + if (method_decl->isInstanceMethod()) + { + is_instance_method = true; + } + else + { + is_instance_method = false; + } + language = eLanguageTypeObjC; + return true; + } + } + return false; +} + diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp index 4291b0c7197..b2bb97fd30b 100644 --- a/lldb/source/Symbol/SymbolContext.cpp +++ b/lldb/source/Symbol/SymbolContext.cpp @@ -13,6 +13,8 @@ #include "lldb/Core/Module.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/Args.h" +#include "lldb/Symbol/Block.h" +#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Symbol.h" @@ -535,7 +537,61 @@ SymbolContext::GetParentOfInlinedScope (const Address &curr_frame_pc, return false; } -ConstString +Block * +SymbolContext::GetFunctionBlock () +{ + if (function) + { + if (block) + { + // If this symbol context has a block, check to see if this block + // is itself, or is contained within a block with inlined function + // information. If so, then the inlined block is the block that + // defines the function. + Block *inlined_block = block->GetContainingInlinedBlock(); + if (inlined_block) + return inlined_block; + + // The block in this symbol context is not inside an inlined + // block, so the block that defines the function is the function's + // top level block, which is returned below. + } + + // There is no block information in this symbol context, so we must + // assume that the block that is desired is the top level block of + // the function itself. + return &function->GetBlock(true); + } + return NULL; +} + +bool +SymbolContext::GetFunctionMethodInfo (lldb::LanguageType &language, + bool &is_instance_method, + ConstString &language_object_name) + + +{ + Block *function_block = GetFunctionBlock (); + if (function_block) + { + clang::DeclContext *decl_context = function_block->GetClangDeclContext(); + + if (decl_context) + { + return ClangASTContext::GetClassMethodInfoForDeclContext (decl_context, + language, + is_instance_method, + language_object_name); + } + } + language = eLanguageTypeUnknown; + is_instance_method = false; + language_object_name.Clear(); + return false; +} + +ConstString SymbolContext::GetFunctionName (Mangled::NamePreference preference) { if (function) diff --git a/lldb/source/Symbol/VariableList.cpp b/lldb/source/Symbol/VariableList.cpp index 1c2bb0d19b9..ad47c6017ff 100644 --- a/lldb/source/Symbol/VariableList.cpp +++ b/lldb/source/Symbol/VariableList.cpp @@ -176,3 +176,40 @@ VariableList::Dump(Stream *s, bool show_context) const } } +lldb::VariableSP +VariableList::FindArtificialObjectVariable (lldb::LanguageType language) const +{ + lldb::VariableSP object_variable_sp; + ConstString object_variable_name; + switch (language) + { + case eLanguageTypeC_plus_plus: + object_variable_name.SetCString("this"); + break; + + case eLanguageTypeObjC: + case eLanguageTypeObjC_plus_plus: + object_variable_name.SetCString("self"); + break; + + default: + break; + } + if (object_variable_name) + { + const_iterator pos, end = m_variables.end(); + for (pos = m_variables.begin(); pos != end; ++pos) + { + Variable *variable = pos->get(); + if (variable->IsArtificial() && + variable->GetScope() == eValueTypeVariableArgument && + variable->GetName() == object_variable_name) + { + object_variable_sp = *pos; + break; + } + } + } + return object_variable_sp; +} + |

