[Lldb-commits] [lldb] r119324 - in /lldb/trunk: include/lldb/Symbol/Type.h source/Expression/ClangExpressionDeclMap.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Symbol/Type.cpp
Greg Clayton
gclayton at apple.com
Mon Nov 15 18:10:55 PST 2010
Author: gclayton
Date: Mon Nov 15 20:10:54 2010
New Revision: 119324
URL: http://llvm.org/viewvc/llvm-project?rev=119324&view=rev
Log:
First attempt and getting "const" C++ method function signatures correct.
It currently isn't working, but it should be close. I will work on this more
when I figure out what I am not doing correctly.
Modified:
lldb/trunk/include/lldb/Symbol/Type.h
lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Symbol/Type.cpp
Modified: lldb/trunk/include/lldb/Symbol/Type.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=119324&r1=119323&r2=119324&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Type.h (original)
+++ lldb/trunk/include/lldb/Symbol/Type.h Mon Nov 15 20:10:54 2010
@@ -223,6 +223,9 @@
m_encoding_type = encoding_type;
}
+ uint32_t
+ GetEncodingMask ();
+
protected:
ConstString m_name;
SymbolFile *m_symbol_file;
Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=119324&r1=119323&r2=119324&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon Nov 15 20:10:54 2010
@@ -1085,6 +1085,14 @@
if (!this_type)
return;
+ if (log)
+ {
+ log->PutCString ("Type for \"this\" is: ");
+ StreamString strm;
+ this_type->Dump(&strm, true);
+ log->PutCString (strm.GetData());
+ }
+
TypeFromUser this_user_type(this_type->GetClangType(),
this_type->GetClangAST());
@@ -1120,12 +1128,20 @@
m_lookedup_types.insert(std::pair<const char*, bool>(name_unique_cstr, true));
// 2 The type is looked up and added, potentially causing more type loookups.
- lldb::TypeSP type = m_sym_ctx.FindTypeByName (name);
+ lldb::TypeSP type_sp (m_sym_ctx.FindTypeByName (name));
- if (type.get())
+ if (type_sp)
{
- TypeFromUser user_type(type->GetClangType(),
- type->GetClangAST());
+ if (log)
+ {
+ log->Printf ("Matching type found for \"%s\": ", name.GetCString());
+ StreamString strm;
+ type_sp->Dump(&strm, true);
+ log->PutCString (strm.GetData());
+ }
+
+ TypeFromUser user_type(type_sp->GetClangType(),
+ type_sp->GetClangAST());
AddOneType(context, user_type, false);
}
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=119324&r1=119323&r2=119324&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Nov 15 20:10:54 2010
@@ -20,6 +20,7 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Specifiers.h"
+#include "clang/Sema/DeclSpec.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
@@ -2235,7 +2236,8 @@
bool skip_artificial,
TypeList* type_list,
std::vector<clang_type_t>& function_param_types,
- std::vector<clang::ParmVarDecl*>& function_param_decls
+ std::vector<clang::ParmVarDecl*>& function_param_decls,
+ unsigned &type_quals
)
{
if (parent_die == NULL)
@@ -2243,7 +2245,7 @@
const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize());
- size_t count = 0;
+ size_t arg_idx = 0;
const DWARFDebugInfoEntry *die;
for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling())
{
@@ -2308,7 +2310,42 @@
if (skip_artificial)
{
if (is_artificial)
+ {
+ // In order to determine if a C++ member function is
+ // "const" we have to look at the const-ness of "this"...
+ // Ugly, but that
+ if (arg_idx == 0)
+ {
+ const DWARFDebugInfoEntry *grandparent_die = parent_die->GetParent();
+ if (grandparent_die && (grandparent_die->Tag() == DW_TAG_structure_type ||
+ grandparent_die->Tag() == DW_TAG_class_type))
+ {
+ LanguageType language = sc.comp_unit->GetLanguage();
+ if (language == eLanguageTypeObjC_plus_plus || language == eLanguageTypeC_plus_plus)
+ {
+ // Often times compilers omit the "this" name for the
+ // specification DIEs, so we can't rely upon the name
+ // being in the formal parameter DIE...
+ if (name == NULL || ::strcmp(name, "this")==0)
+ {
+ Type *this_type = ResolveTypeUID (param_type_die_offset);
+ if (this_type)
+ {
+ uint32_t encoding_mask = this_type->GetEncodingMask();
+ if (encoding_mask & Type::eEncodingIsPointerUID)
+ {
+ if (encoding_mask & (1u << Type::eEncodingIsConstUID))
+ type_quals |= clang::DeclSpec::TQ_const;
+ if (encoding_mask & (1u << Type::eEncodingIsVolatileUID))
+ type_quals |= clang::DeclSpec::TQ_volatile;
+ }
+ }
+ }
+ }
+ }
+ }
skip = true;
+ }
else
{
@@ -2336,6 +2373,7 @@
}
}
}
+ arg_idx++;
}
break;
@@ -2343,7 +2381,7 @@
break;
}
}
- return count;
+ return arg_idx;
}
size_t
@@ -3257,7 +3295,8 @@
skip_artificial,
type_list,
function_param_types,
- function_param_decls);
+ function_param_decls,
+ type_quals);
}
// clang_type will get the function prototype clang type after this call
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=119324&r1=119323&r2=119324&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Mon Nov 15 20:10:54 2010
@@ -255,7 +255,8 @@
bool skip_artificial,
lldb_private::TypeList* type_list,
std::vector<lldb::clang_type_t>& function_args,
- std::vector<clang::ParmVarDecl*>& function_param_decls);
+ std::vector<clang::ParmVarDecl*>& function_param_decls,
+ unsigned &type_quals);
size_t ParseChildEnumerators(
const lldb_private::SymbolContext& sc,
Modified: lldb/trunk/source/Symbol/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=119324&r1=119323&r2=119324&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Type.cpp (original)
+++ lldb/trunk/source/Symbol/Type.cpp Mon Nov 15 20:10:54 2010
@@ -601,6 +601,16 @@
return child_qual_type;
}
+uint32_t
+lldb_private::Type::GetEncodingMask ()
+{
+ uint32_t encoding_mask = 1u << m_encoding_uid_type;
+ Type *encoding_type = GetEncodingType();
+ assert (encoding_type != this);
+ if (encoding_type)
+ encoding_mask |= encoding_type->GetEncodingMask ();
+ return encoding_mask;
+}
clang_type_t
lldb_private::Type::GetClangType ()
More information about the lldb-commits
mailing list