Commit 0710b0e1 authored by ussrhero's avatar ussrhero

fixed nested enum values

parent f51b59fe
......@@ -150,6 +150,10 @@ struct structWithNested {
enum {
NestConst = 123
};
enum NestedEnum {
NestConst1 = 345
};
};
extern structWithNested g_structWithNested;
......
......@@ -819,13 +819,14 @@ TypedVarPtr TypedVarUdt::getElement( const std::wstring& fieldName )
if ( m_typeInfo->isStaticMember(fieldName) )
{
MEMOFFSET_64 staticOffset = m_typeInfo->getElementVa(fieldName);
//if ( staticOffset == 0 )
// NOT_IMPLEMENTED();
return loadTypedVar( fieldType, staticOffset );
}
if (fieldType->isConstant())
{
return TypedValue(fieldType->getValue()).get();
}
MEMOFFSET_32 fieldOffset = m_typeInfo->getElementOffset(fieldName);
if ( m_typeInfo->isVirtualMember( fieldName ) )
......
......@@ -890,6 +890,11 @@ std::wstring TypeInfoFields::print()
{
TypeFieldPtr udtField = m_fields.lookup(i);
if (udtField->isConstMember())
{
continue;
}
else
if ( udtField->isStaticMember() )
{
sstr << L" =" << std::right << std::setw(10) << std::setfill(L'0') << std::hex << udtField->getStaticOffset();
......@@ -1401,7 +1406,9 @@ void TypeInfoUdt::getFields(
{
TypeFieldPtr fieldPtr;
switch ( childSym->getDataKind() )
auto dataKind = childSym->getDataKind();
switch (dataKind )
{
case DataIsMember:
if ( baseVirtualSym )
......@@ -1413,21 +1420,32 @@ void TypeInfoUdt::getFields(
fieldPtr = SymbolUdtField::getField( childSym, childSym->getName(), startOffset + childSym->getOffset() );
}
break;
case DataIsStaticMember:
std::wstring fieldName = childSym->getName();
MEMOFFSET_64 staticOffset = 0L;
try
case DataIsStaticMember:
{
staticOffset = childSym->getVa();
std::wstring fieldName = childSym->getName();
MEMOFFSET_64 staticOffset = 0L;
try
{
staticOffset = childSym->getVa();
}
catch (SymbolException&)
{
}
fieldPtr = SymbolUdtField::getStaticField(childSym, fieldName, staticOffset);
}
catch(SymbolException& )
{}
fieldPtr = SymbolUdtField::getStaticField(childSym, fieldName, staticOffset);
break;
case DataIsConstant:
fieldPtr = SymbolUdtField::getConstField(childSym, childSym->getName());
break;
default:
throw TypeException(m_name, L"Unsupported field type");
}
m_fields.push_back( fieldPtr );
......@@ -1448,8 +1466,12 @@ void TypeInfoUdt::getFields(
m_fields.push_back( fieldPtr );
}
}
else
if (symTag == SymTagEnum)
{
getFields(childSym, SymbolPtr(), startOffset);
}
}
}
///////////////////////////////////////////////////////////////////////////////
......
......@@ -51,8 +51,14 @@ public:
MEMOFFSET_REL getOffset() const
{
if ( m_staticOffset != 0 )
throw TypeException( m_name, L"static field has only virtual address" );
if ( m_staticMember )
throw TypeException( m_name, L"static field has no offset" );
if (m_methodMember )
throw TypeException(m_name, L"method has no offset");
if (m_constMember)
throw TypeException(m_name, L"constatnt has no offset");
return m_offset;
}
......@@ -72,6 +78,11 @@ public:
return m_methodMember;
}
bool isConstMember() const
{
return m_constMember;
}
MEMOFFSET_64 getStaticOffset() const
{
if ( m_staticMember )
......@@ -107,7 +118,8 @@ protected:
m_virtualDispSize( 0 ),
m_staticMember( false ),
m_virtualMember( false ),
m_methodMember(false)
m_methodMember(false),
m_constMember(false)
{}
std::wstring m_name;
......@@ -125,6 +137,7 @@ protected:
bool m_staticMember;
bool m_virtualMember;
bool m_methodMember;
bool m_constMember;
};
///////////////////////////////////////////////////////////////////////////////////
......@@ -154,6 +167,15 @@ public:
return TypeFieldPtr(p);
}
static TypeFieldPtr getConstField(
const SymbolPtr &sym,
const std::wstring& name)
{
SymbolUdtField *p = new SymbolUdtField(sym, name);
p->m_constMember = true;
return TypeFieldPtr(p);
}
static TypeFieldPtr getVirtualField(
const SymbolPtr &sym,
const std::wstring& name,
......
......@@ -388,7 +388,7 @@ TEST_F(ClangTest, TypeProviderEnum)
ASSERT_NO_THROW( typeEnum = typeProvider->getTypeEnumerator(L"struct*") );
for ( count = 0; 0 != typeEnum->Next(); ++count);
EXPECT_EQ(13, count);
EXPECT_EQ(14, count);
}
......
......@@ -719,10 +719,11 @@ TEST_F(TypedVarTest, GetSource)
ASSERT_NO_THROW(funcptr = loadTypedVar(L"classChild::childMethod"));
funcptr->getSourceLine(funcptr->getAddress(), fileName, lineNo);
EXPECT_EQ(282, lineNo);
EXPECT_EQ(286, lineNo);
}
TEST_F(TypedVarTest, StructNestedEnum)
{
EXPECT_EQ(g_structWithEnum.digit, *loadTypedVar(L"g_structWithEnum")->getElement(L"digit"));
EXPECT_EQ(g_structWithNested.NestConst, *loadTypedVar(L"g_structWithNested")->getElement(L"NestConst"));
}
......@@ -351,6 +351,8 @@ TEST_F( TypeInfoTest, Str )
{
std::wstring str;
ASSERT_NO_THROW( str = loadType(L"enumType")->str() );
ASSERT_NO_THROW( str = loadType(L"structWithNested")->str() );
ASSERT_NO_THROW(str = loadType(L"g_virtChild")->str());
}
......@@ -619,7 +621,7 @@ TEST_F(TypeInfoTest, PdbProviderEnum)
ASSERT_NO_THROW( typeEnum = typeProvider->getTypeEnumerator(L"struct*") );
for ( count = 0; 0 != typeEnum->Next(); ++count);
EXPECT_EQ(12, count);
EXPECT_EQ(16, count);
}
TEST_F(TypeInfoTest, TemplateStruct)
......@@ -634,5 +636,6 @@ TEST_F(TypeInfoTest, TemplateStruct)
TEST_F(TypeInfoTest, StructNestedEnum)
{
EXPECT_EQ(structWithNested::NestConst, *loadType(L"structWithNested")->getElement(L"NestConst"));
EXPECT_EQ(structWithNested::NestConst1, *loadType(L"structWithNested")->getElement(L"NestConst1"));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment