fixed a potential memory leak ; small improvement in the formatters lookup algorithm

llvm-svn: 136945
This commit is contained in:
Enrico Granata 2011-08-04 23:37:18 +00:00
parent f01a7ddcd6
commit cd1c0236fe
3 changed files with 22 additions and 10 deletions

View File

@ -351,16 +351,28 @@ private:
return false;
}
ConstString name(ClangASTType::GetTypeNameForQualType(type).c_str());
const char* typeName = name.GetCString();
if (vobj.GetBitfieldBitSize() > 0)
{
// for bitfields, append size to the typename so one can custom format them
StreamString sstring;
sstring.Printf("%s:%d",name.AsCString(),vobj.GetBitfieldBitSize());
name = ConstString(sstring.GetData());
sstring.Printf("%s:%d",typeName,vobj.GetBitfieldBitSize());
ConstString bitfieldname = ConstString(sstring.GetData());
if (log)
log->Printf("appended bitfield info, final result is %s", name.GetCString());
log->Printf("appended bitfield info, final result is %s", bitfieldname.GetCString());
if (Get(bitfieldname.AsCString(), entry))
{
if (log)
log->Printf("bitfield direct match found, returning");
return true;
}
else
{
reason |= lldb::eFormatterChoiceCriterionStrippedBitField;
if (log)
log->Printf("no bitfield direct match");
}
}
const char* typeName = name.GetCString();
if (log)
log->Printf("trying to get %s for VO name %s of type %s",
m_name.c_str(),

View File

@ -507,7 +507,8 @@ namespace lldb {
eFormatterChoiceCriterionNavigatedBaseClasses = 0x00000004,
eFormatterChoiceCriterionRegularExpressionSummary = 0x00000008,
eFormatterChoiceCriterionRegularExpressionFilter = 0x00000008,
eFormatterChoiceCriterionDynamicObjCHierarchy = 0x00000010
eFormatterChoiceCriterionDynamicObjCHierarchy = 0x00000010,
eFormatterChoiceCriterionStrippedBitField = 0x00000020
} FormatterChoiceCriterion;
//----------------------------------------------------------------------

View File

@ -953,7 +953,7 @@ ValueObject::GetPrintableRepresentation(Stream& s,
SetFormat(custom_format);
const char * return_value;
std::auto_ptr<char> alloc_mem;
std::string alloc_mem;
switch(val_obj_display)
{
@ -970,12 +970,11 @@ ValueObject::GetPrintableRepresentation(Stream& s,
return_value = GetLocationAsCString();
break;
case eDisplayChildrenCount:
// keep this out of the local scope so it will only get deleted when
// we exit the function (..and we have a copy of the data into the Stream)
alloc_mem = std::auto_ptr<char>((char*)(return_value = new char[512]));
{
alloc_mem.resize(512);
return_value = &alloc_mem[0];
int count = GetNumChildren();
snprintf(alloc_mem.get(), 512, "%d", count);
snprintf((char*)return_value, 512, "%d", count);
break;
}
default: