User forums > Using Code::Blocks
"Complete code" do not support "XXX const& "
nanyu:
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
ollydbg:
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. :)
ollydbg:
When parsing string (function arguments):
--- Code: ---Msg const * pmsg;
--- End code ---
I see:
a variable Token named "pmsg" is added, but its basetype is "const" which is wrong.
--- Code: ---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
}
--- End code ---
For the above function: the input string is "Msg const", but the output string (basetype) is "const", well, this is the reason of bug.
MortenMacFly:
--- 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.
--- End quote ---
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.
ollydbg:
I'm not quite sure, but I think this code snippet:
--- Code: --- else if (token == ParserConsts::kw_const)
{
m_Str << token << _T(" ");
}
--- End code ---
Can be improved, one simple way was just skip the "const" keyword, or do the similar thing like:
--- Code: --- case ParserConsts::ptr_chr:
{
m_PointerOrRef << token;
}
break;
--- End code ---
Maybe, we can add a member variable like "m_IsConst" of Parserthread class.
Any ideas?
Navigation
[0] Message Index
[#] Next page
Go to full version