Author Topic: calculation of BaseType has changed?  (Read 12336 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
calculation of BaseType has changed?
« on: March 16, 2012, 03:41:54 pm »
I see many bug report said that BaseType lost the "*", I'm not sure this is a regression or a long time bug.

See:

Functions returning T* are displayed as returning T

or

Insert all class methods without implementation malfunction
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: calculation of BaseType has changed?
« Reply #1 on: March 16, 2012, 05:25:18 pm »
I see many bug report said that BaseType lost the "*", I'm not sure this is a regression or a long time bug.
You can easily find out by trying with 10/05 or 08/02.

BTW: I think there are actually two issues: First, the correct type of functions / methods is not found due to what I have commented in ParserThread::GetTokenBaseType() (I am working on that but its not so easy). For the other one: If is is working safely with FullType its OK, but I wonder if the actual error is that the base type gets truncated. What's in full/base type at that moment for the samples in the bug tracker?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: calculation of BaseType has changed?
« Reply #2 on: March 17, 2012, 08:34:00 am »
What's in full/base type at that moment for the samples in the bug tracker?
CC has such code snippet to set full/base type.

Code
    if (!(kind & (tkConstructor | tkDestructor)))
    {
        wxString tokenFullType = m_Str;
        if (!m_PointerOrRef.IsEmpty())
        {
            tokenFullType << m_PointerOrRef;
            m_PointerOrRef.Clear();
        }
        wxString tokenBaseType = GetTokenBaseType();
        if (tokenBaseType.Find(ParserConsts::space_chr) == wxNOT_FOUND)
        {
            // token type must contain all namespaces
            wxString prepend;

            // Notice: clears the queue "m_EncounteredTypeNamespaces", too
            while (!m_EncounteredTypeNamespaces.empty())
            {
                prepend << m_EncounteredTypeNamespaces.front() << ParserConsts::dcolon;
                m_EncounteredTypeNamespaces.pop();
            }

            TRACE(_T("DoAddToken() : Prepending '%s'"), prepend.wx_str());
            tokenBaseType.Prepend(prepend);
        }
        newToken->m_FullType = tokenFullType;
        newToken->m_BaseType = tokenBaseType;
    }

    newToken->m_IsLocal    = m_IsLocal;
    newToken->m_IsTemp     = m_Options.isTemp;
    newToken->m_IsOperator = isOperator;

So, the fulltype is "char*", and the basetype is "char", so it looks like we can safely use m_FullType, right?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: calculation of BaseType has changed?
« Reply #3 on: March 17, 2012, 09:20:16 am »
So, the fulltype is "char*", and the basetype is "char", so it looks like we can safely use m_FullType, right?
Looks like that... why don't you try? I wonder is that works for e.g. template specialisation, too.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: calculation of BaseType has changed?
« Reply #4 on: March 17, 2012, 09:37:31 am »
So, the fulltype is "char*", and the basetype is "char", so it looks like we can safely use m_FullType, right?
Looks like that... why don't you try? I wonder is that works for e.g. template specialisation, too.
oh, i have debuged that already. ha.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: calculation of BaseType has changed?
« Reply #5 on: March 18, 2012, 02:47:39 am »
BTW: I think there are actually two issues: First, the correct type of functions / methods is not found due to what I have commented in ParserThread::GetTokenBaseType() (I am working on that but its not so easy).

Code
    // TODO (Morten#5#): Handle stuff like the following gracefully:
    // int __cdecl __MINGW_NOTHROW vscanf (const char * __restrict__, __VALIST);

1, we can add a function like "RemoveAttributeSpecifier()", so we can remove something like: __cdecl  or __stdcall
2, __MINGW_NOTHROW can be macro replaced, either to an empty string, or to #define __MINGW_NOTHROW __attribute__ ((__nothrow__)), and I think the __attribute__ should be removed in the RemoveAttributeSpecifier().
3, we can heuristically remove all the tokens like "__XXXXXX".
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.