Test code:
void g_func1(){ } void ClassA::func1(){ } void ClassA::func2(){ } void ClassB::func1(){ } void ClassB::func2(){ } namespace NamespaceA{ void func2(){ } void ClassC::func1(){ } void ClassC::func2(){ } }
And when you look at the Toolbar, under the scope "NamespaceA::ClassC", you see only one member.
Debug the data, I see inside the function void CodeCompletion::ParseFunctionsAndFillToolbar()
If I try to see the value of m_FunctionsScope. I get such results from GDB.
std::vector of length 8, capacity 8 = { {StartLine = 0, EndLine = 1, ShortName = L"g_func1", Name = L"g_func1() : void", Scope = L"<global>"}, {StartLine = 3, EndLine = 4, ShortName = L"func1", Name = L"func1() : void", Scope = L"ClassA::"}, {StartLine = 6, EndLine = 7, ShortName = L"func2", Name = L"func2() : void", Scope = L"ClassA::"}, {StartLine = 9, EndLine = 10, ShortName = L"func1", Name = L"func1() : void", Scope = L"ClassB::"}, {StartLine = 12, EndLine = 13, ShortName = L"func2", Name = L"func2() : void", Scope = L"ClassB::"}, {StartLine = 14, EndLine = 23, ShortName = L"", Name = L"", Scope = L"NamespaceA::"}, {StartLine = 22, EndLine = 23, ShortName = L"func2", Name = L"func2() : void", Scope = L"NamespaceA::"}, {StartLine = 19, EndLine = 20, ShortName = L"func1", Name = L"func1() : void", Scope = L"NamespaceA::ClassC::"} }
You see, there are one token which has the name L"". And you also see one token under the scope "NamespaceA::ClassC"
I just create a simple test file named ccc_ticket_256.cpp
And run under cctest, I get:
Note that if I change the test file to the below: (change the first "func2" to "func3")
And I get the good result
Not sure the reason of such bug.
Inside the function: DoAddToken()
When adding the third function ClassC::func2, the first piece of the above code failed, and at this time, we should create a Token under the localParent parent. Note at this time, the localParent is the "NamespaceA::ClassC". and the m_LastParent is the "NamespaceA".
When searching for the third function, which is NamespaceA::ClassC::func2, the first token is wrongly located by the following code, which is actually NamespaceA::func2. I think the below code is just used to workaround some issues.
Last edit: ollydbg 2015-11-18
This is the first code snippet to add the code(in year 2006)
Which means if we try to find ClassC::func2 inside the NamespaceA, but at this time, func2 token is not created, we will try to search the "func2" under NamespaceA, it is totally wrong, as it will overwrite the already added token NamespaceA::func2.
An idea is just to remove such piece of code, but it could cause other bugs...
I just run the cctest on all the test cases, and I don't see any regressions if I comment out:
This test works OK, normally, I think a class definition(the above class ClassC definition) should put before the function implementation.