struct Msg
{
...
};
void foo1(Msg* pmsg)
{
pmsg-> //<-- OK, c::b will show tooltip.
}
BUT
void foo2(Msg const * const pmsg)
{
pmsg-> // c::b show nothing...
}
AND
void foo3(Msg const * pmsg)
{
pmsg-> // c::b show nothing...
}
//////////
redhat linux KDE
c::b 12.11
I can confirm this, thanks.
I will dig into it. Hopefully it was not hard to fix this by removing all "const" keyword in handling function arguments. :)
When parsing string (function arguments):
Msg const * pmsg;
I see:
a variable Token named "pmsg" is added, but its basetype is "const" which is wrong.
wxString ParserThread::GetTokenBaseType()
{
TRACE(_T("GetTokenBaseType() : Searching within m_Str='%s'"), m_Str.wx_str());
// Compensate for spaces between namespaces (e.g. NAMESPACE :: SomeType)
// which is valid C++ construct.
// Also, spaces that follow a semicolon are removed.
int pos = 0;
while (pos < (int)m_Str.Length())
{
if ( (m_Str.GetChar(pos) == ParserConsts::space_chr)
&& ( ( (pos > 0)
&& (m_Str.GetChar(pos - 1) == ParserConsts::colon_chr) )
|| ( (pos < (int)m_Str.Length() - 1)
&& (m_Str.GetChar(pos + 1) == ParserConsts::colon_chr) ) ) )
{
m_Str.Remove(pos, 1);
}
else
++pos;
}
TRACE(_T("GetTokenBaseType() : Compensated m_Str='%s'"), m_Str.wx_str());
// TODO (Morten#5#): Handle stuff like the following gracefully:
// int __cdecl __MINGW_NOTHROW vscanf (const char * __restrict__, __VALIST);
// m_Str contains the full text before the token's declaration
// an example m_Str value would be: const wxString&
// what we do here is locate the actual return value (wxString in this example)
// it will be needed by code completion code ;)
pos = m_Str.Length() - 1;
// we walk m_Str backwards until we find a non-space character which also is
// not * or &
// const wxString&
// in this example, we would stop here ^
while ( (pos >= 0)
&& ( wxIsspace(m_Str.GetChar(pos))
|| (m_Str.GetChar(pos) == ParserConsts::ptr_chr)
|| (m_Str.GetChar(pos) == ParserConsts::ref_chr)) )
{
--pos;
}
if (pos >= 0)
{
// we have the end of the word we're interested in
int end = pos;
// continue walking backwards until we find the start of the word
// const wxString&
// in this example, we would stop here ^
while ( (pos >= 0)
&& ( wxIsalnum(m_Str.GetChar(pos))
|| (m_Str.GetChar(pos) == ParserConsts::underscore_chr)
|| (m_Str.GetChar(pos) == ParserConsts::colon_chr)) )
{
--pos;
}
TRACE(_T("GetTokenBaseType() : Found '%s'"), m_Str.Mid(pos + 1, end - pos).wx_str());
return m_Str.Mid(pos + 1, end - pos);
}
TRACE(_T("GetTokenBaseType() : Returning '%s'"), m_Str.wx_str());
return m_Str; // token ends at start of phrase
}
For the above function: the input string is "Msg const", but the output string (basetype) is "const", well, this is the reason of bug.
Quote from: ollydbg on May 02, 2013, 06:59:29 AM
For the above function: the input string is "Msg const", but the output string (basetype) is "const", well, this is the reason of bug.
Feel free to fix this bug but in this special case: Could you please provide a patch in advance? I am working on that part myself, to improve the base type detection in case of macros. So a patch helps me to integrate your changes into my code base more easier.
I'm not quite sure, but I think this code snippet:
else if (token == ParserConsts::kw_const)
{
m_Str << token << _T(" ");
}
Can be improved, one simple way was just skip the "const" keyword, or do the similar thing like:
case ParserConsts::ptr_chr:
{
m_PointerOrRef << token;
}
break;
Maybe, we can add a member variable like "m_IsConst" of Parserthread class.
Any ideas?
Quote from: ollydbg on May 02, 2013, 04:02:30 PM
Any ideas?
Hmm... this might work, indeed. I would need to check the use of m_PointerOrRef though... I don't recall if it
really should only be * or &...
Quote from: MortenMacFly on May 02, 2013, 04:04:51 PM
Quote from: ollydbg on May 02, 2013, 04:02:30 PM
Any ideas?
Hmm... this might work, indeed. I would need to check the use of m_PointerOrRef though... I don't recall if it really should only be * or &...
I just edit my previous post, and said:
QuoteMaybe, we can add a member variable like "m_IsConst" of Parserthread class.
I mean we can add another member variable to remember whether we have meet a "const" keyword.
Quote from: ollydbg on May 02, 2013, 04:09:45 PM
I mean we can add another member variable to remember whether we have meet a "const" keyword.
Even better. :-)
hi all....
This problem still exists......
do we have a solution?
----
ubuntu codeblocks svn9744
struct Msg
{
int a;
int b;
};
void foo_1(const Msg& msg)
{
msg. //<- OK! cc work well
}
void foo_2(Msg const& msg)
{
msg. //<- ?? cc don't work.
}
@nanyu, committed r9754 should fix your problem. Thanks for the report!
@Morten, I choose a simple fix by specially handling the "const" in ParserThread::GetTokenBaseType().
Thank you!!