News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

New code completion remarks/issues

Started by killerbot, September 15, 2009, 12:24:28 PM

Previous topic - Next topic

ollydbg

I'm sorry, I find the bug, it's here

line 766-787 of nativeparser.cpp.


            if (!token->m_Args.IsEmpty() && !token->m_Args.Matches(_T("()")))
            {
                wxString buffer = token->m_Args;
                buffer.Remove(0, 1); // remove (
                buffer.RemoveLast(); // remove )
                buffer.Replace(_T(","), _T(";")); // replace commas with semi-colons
                buffer << _T(';'); // aid parser ;)
                buffer.Trim();

                if (s_DebugSmartSense)
                {
                #if wxCHECK_VERSION(2, 9, 0)
                    Manager::Get()->GetLogManager()->DebugLog(F(_T("Parsing arguments: \"%s\""), buffer.wx_str()));
                #else
                    Manager::Get()->GetLogManager()->DebugLog(F(_T("Parsing arguments: \"%s\""), buffer.c_str()));
                #endif
                    if (!buffer.IsEmpty() && !parser->ParseBuffer(buffer, false, false, true))
                    {
                        Manager::Get()->GetLogManager()->DebugLog(_T("ERROR parsing arguments"));
                    }
                }
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.

MortenMacFly

#166
Quote from: ollydbg on October 09, 2009, 08:02:02 AM
I'm sorry, I find the bug, it's here
line 766-787 of nativeparser.cpp.
...so?! What exactly is wrong with that portion?
...besides: it works fine here (trunk)...?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

ollydbg

Quote from: MortenMacFly on October 09, 2009, 08:05:53 AM
Quote from: ollydbg on October 09, 2009, 08:02:02 AM
I'm sorry, I find the bug, it's here
line 766-787 of nativeparser.cpp.
...so?! What exactly is wrong with that portion?

The code is wrapped in the if (s_DebugSmartSense )from rev 5840 to 5845 of the nativeparser.cpp.
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.

MortenMacFly

Quote from: ollydbg on October 09, 2009, 08:09:33 AM
The code is wrapped in the if (s_DebugSmartSense )from rev 5840 to 5845 of the nativeparser.cpp.
Argh! Good one. Nevermind... my mistake. :oops: I was always using it *with* DebugSmartSense enabled, so that's why it worked here... Will commit the fix soon...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

ollydbg

Quote from: MortenMacFly on October 09, 2009, 08:14:11 AM
Quote from: ollydbg on October 09, 2009, 08:09:33 AM
The code is wrapped in the if (s_DebugSmartSense )from rev 5840 to 5845 of the nativeparser.cpp.
Argh! Good one. Nevermind... my mistake. :oops: I was always using it *with* DebugSmartSense enabled, so that's why it worked here... Will commit the fix soon...

haha, I think one reason of the mistake:  #if wxCHECK_VERSION(2, 9, 0)  preprocessor guard is a little annoying. :D
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.

MortenMacFly

Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

mmkider


blueshake

Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

blueshake

Dear ollydbg:
had you tried on reply #155?
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

daniloz

Quick question... in the structs_typedefs.cpp (from the tests - thx Morten):

struct _s
{
  int   x;
  float y;
};
typedef struct _s t_s;

typedef struct _s_inner
{
int z_inner;
} t_s_inner;


C::B shows "t_s" as a typedef, BUT "t_s_inner" as a class. Is this a bug or a feature? :D

Btw, I was expecting to see "t_s_inner" as a typedef... ;)

daniloz

PS: why are structs treated as class by the CC?

blueshake

Quote from: daniloz on October 09, 2009, 08:49:56 AM
Quick question... in the structs_typedefs.cpp (from the tests - thx Morten):

struct _s
{
  int   x;
  float y;
};
typedef struct _s t_s;

typedef struct _s_inner
{
int z_inner;
} t_s_inner;


C::B shows "t_s" as a typedef, BUT "t_s_inner" as a class. Is this a bug or a feature? :D

Btw, I was expecting to see "t_s_inner" as a typedef... ;)

daniloz

PS: why are structs treated as class by the CC?



not a bug,I do this.read the codes about void ParserThread::ReadClsNames(wxString& ancestor)
as I kown ,there is a bug in typedef handle .so......
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

blueshake

Quote from: daniloz on October 09, 2009, 08:49:56 AM
Quick question... in the structs_typedefs.cpp (from the tests - thx Morten):

struct _s
{
  int   x;
  float y;
};
typedef struct _s t_s;

typedef struct _s_inner
{
int z_inner;
} t_s_inner;


C::B shows "t_s" as a typedef, BUT "t_s_inner" as a class. Is this a bug or a feature? :D

Btw, I was expecting to see "t_s_inner" as a typedef... ;)

daniloz

PS: why are structs treated as class by the CC?



fixed.


and fixed the typedef issue.
test codes:
struct _s
{
  int   x;
  float y;
};
typedef struct _s t_s;
typedef t_s ssss;

ssss.

patch:
Index: src/plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- src/plugins/codecompletion/parser/parserthread.cpp (revision 5859)
+++ src/plugins/codecompletion/parser/parserthread.cpp (working copy)
@@ -1795,13 +1795,15 @@
                   current.c_str(),
                   m_Str.c_str(),
                   (m_pLastParent ? m_pLastParent->m_Name.c_str():_T("<no-parent>")));
-            Token* newToken = DoAddToken(tkClass, current, m_Tokenizer.GetLineNumber());
+            Token* newToken = DoAddToken(tkTypedef, current, m_Tokenizer.GetLineNumber());
             if (!newToken)
                 break;
             else
             {
                 wxString tempAncestor = ancestor;
                 newToken->m_AncestorsString = tempAncestor;
+                newToken->m_ActualType = tempAncestor;
+                newToken->m_Type = tempAncestor;
             }
         }
         else // unexpected
Index: src/plugins/codecompletion/parser/token.cpp
===================================================================
--- src/plugins/codecompletion/parser/token.cpp (revision 5859)
+++ src/plugins/codecompletion/parser/token.cpp (working copy)
@@ -865,7 +865,7 @@
                 {
                     Token* ancestorToken = at(*it);
                     // only classes take part in inheritance
-                    if (ancestorToken && ancestorToken != token && (ancestorToken->m_TokenKind == tkClass || ancestorToken->m_TokenKind == tkEnum))// && !ancestorToken->m_IsTypedef)
+                    if (ancestorToken && ancestorToken != token && (ancestorToken->m_TokenKind == tkClass || ancestorToken->m_TokenKind == tkEnum || ancestorToken->m_TokenKind == tkTypedef))// && !ancestorToken->m_IsTypedef)
                     {
                         token->m_Ancestors.insert(*it);
                         ancestorToken->m_Descendants.insert(i);
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

ollydbg

#177
Here is the patch to add TRACE to the token.cpp.

Also, this patch contains the previous post's patch by blueshake.

Currently, If you test the structs_typedefs.cbp.

Only these statements below failed.


//    t_ptr.
//    t_ptr(3,3).


PS: Is it a typo? the original code is:


//    t_ptr_s(
//    t_ptr_s(3,3).




[attachment deleted by admin]
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.

ollydbg

#178
This is the testing patch for parsing the Macros for GCC 4.x

See the screenshot.



You should also change these section in your default.conf file. Just search by "TOKEN_REPLACEMENTS"




<TOKEN_REPLACEMENTS>
<ssmap>
<_GLIBCXX_BEGIN_NAMESPACE>
<![CDATA[+namespace]]>
</_GLIBCXX_BEGIN_NAMESPACE>
<_GLIBCXX_BEGIN_NAMESPACE_TR1>
<![CDATA[-namespace tr1 {]]>
</_GLIBCXX_BEGIN_NAMESPACE_TR1>
<_GLIBCXX_BEGIN_NESTED_NAMESPACE>
<![CDATA[+namespace]]>
</_GLIBCXX_BEGIN_NESTED_NAMESPACE>
<_GLIBCXX_END_NAMESPACE>
<![CDATA[}]]>
</_GLIBCXX_END_NAMESPACE>
<_GLIBCXX_END_NAMESPACE_TR1>
<![CDATA[}]]>
</_GLIBCXX_END_NAMESPACE_TR1>
<_GLIBCXX_END_NESTED_NAMESPACE>
<![CDATA[}]]>
</_GLIBCXX_END_NESTED_NAMESPACE>
<_GLIBCXX_STD>
<![CDATA[std]]>
</_GLIBCXX_STD>
</ssmap>
</TOKEN_REPLACEMENTS>



I'm still testing... :D

Edit

it seems works OK!



[attachment deleted by admin]
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.

blueshake

What I want to know is if doing this wil slow down the parse process?
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?