Bug #18526 2012-03-09 14:12

zetab

Insert all class methods without implementation malfunction

Version: svn build rev 7789 (2012/02/11 03:42:39) gcc 4.5.2 Windows/unicode - 32 bit

OS: WinXP

Declare a class:

class TestClass

{

public:

TestClass();

~TestClass();

int* Test1();

int& Test2();

unsigned int Test3();

protected:

private:

};

Using "Insert -> all class methods without implementation" for Test1, Test2, and Test3 will generate following code:

int TestClass::Test1()

{

}

int TestClass::Test2()

{

}

int TestClass::Test3()

{

}

The "*", "&" and "unsigned" in the return type are missing.

Category
Plugin::CodeCompletion
Group
Platform:Windows
Status
Open
Close date
 
Assigned to
ollydbg
ollydbg 2012-03-12 06:09
Here, in the function: int CodeCompletion::DoAllMethodsImpl(), we have such code:

wxString type = token->m_BaseType;
            if ((type.Last() == _T('&') || type.Last() == _T('*')) && type[type.Len() - 2] == _T(' '))
            {
                type[type.Len() - 2] = type.Last();
                type.RemoveLast();
            }

But both three tokens have the same "base type". Do shall we use "m_FullType" instead?



zetab 2012-03-21 10:36

Found another problem:

If I have another class:

class A

{

public:

A(int x, int y){}

~A(){}

};

And declare a member function in TestClass:

void Test4(const A& a = A(1, 2));

Insert implementation will result in:

void TestClass::Test4(const A& a, 2))

{

}

ollydbg 2012-03-21 12:48

Hi, thanks for this report, I believe this is another bug, and I will look into it. Thanks.

ollydbg 2012-03-21 13:45
wxString Token::GetStrippedArgs() const
{
    // the argument should have the format (xxxx = y, ....) or just an empty string
    // if it is empty, we just return an empty string
    if (m_Args.IsEmpty())
        return wxEmptyString;

    wxString args;
    args.Alloc(m_Args.Len() + 1);
    bool skipDefaultValue = false;
    for (size_t i = 0; i < m_Args.Len(); ++i)
    {
        const wxChar ch = m_Args[i];
        if (ch == _T('\n'))
            continue;
        else if (ch == _T('='))
        {
            skipDefaultValue = true;
            args.Trim();
        }
        else if (ch == _T(','))
            skipDefaultValue = false;

        if (!skipDefaultValue)
            args << ch;
    }

    if (args.Last() != _T(')'))
        args << _T(')');

    return args;
}
This function works badly when m_Args="(const A& a = A(1, 2))".
ollydbg 2012-03-24 14:22

Now, I see skipping parentheses is quite complex. See:

void Tokenizer::ReadParentheses(wxString& str)

ollydbg 2012-05-09 14:35

I add a new bug report about your second bug in this thread.

https://developer.berlios.de/bugs/?func=detailbug&bug_id=18600&group_id=5358

Here, I will focus on the original bug.