News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Please help me fix it, I find the reasons!

Started by Loaden, May 31, 2009, 06:15:08 PM

Previous topic - Next topic

Loaden

I found that VC compiler auto-complete function can not be used for it.
Because the VC header files is special, example:
class ATL_NO_VTABLE CHyperLinkImpl : public ATL::CWindowImpl< T, TBase, TWinTraits >
{
public:
LPTSTR m_lpstrLabel;
LPTSTR m_lpstrHyperLink;

HCURSOR m_hCursor;
HFONT m_hFont;
HFONT m_hFontNormal;

if remove ATL_NO_VTABLE, it's became:
class CHyperLinkImpl : public ATL::CWindowImpl< T, TBase, TWinTraits >
{
public:


it's work fine!
Have any way to fix it?
Thanks!!

MortenMacFly

Quote from: Loaden on May 31, 2009, 06:15:08 PM
Have any way to fix it?
You can try the CC replacements -> replace ATL_NO_VTABLE with "" (nothing).
Settings -> Editor -> CC & Symbols browser -> Tab "C++ parser" -> Add a "replacement" token.
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]

Loaden

Quote from: MortenMacFly on May 31, 2009, 08:34:57 PM
Quote from: Loaden on May 31, 2009, 06:15:08 PM
Have any way to fix it?
You can try the CC replacements -> replace ATL_NO_VTABLE with "" (nothing).
Settings -> Editor -> CC & Symbols browser -> Tab "C++ parser" -> Add a "replacement" token.
Thanks!
But i can't add replacement ATL_NO_VTABLE with nothing.


[attachment deleted by admin]

ollydbg

In the ccoptiondlg.cpp.

bool CCOptionsDlg::ValidateReplacementToken(wxString& from, wxString& to)
{
    wxRegEx re(_T("[A-Za-z_]+[0-9]*[A-Za-z_]*"));
    from.Trim(true).Trim(false);
    to.Trim(true).Trim(false);
    if (!re.Matches(from) || !re.Matches(to))
    {
        cbMessageBox(_("Replacement tokens can only contain alphanumeric characters and underscores..."),
                    _("Error"), wxICON_ERROR);
        return false;
    }
    return true;
}


That's the cause of your problem.
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.

Loaden

Quote from: ollydbg on June 01, 2009, 05:31:55 AM
In the ccoptiondlg.cpp.

bool CCOptionsDlg::ValidateReplacementToken(wxString& from, wxString& to)
{
    wxRegEx re(_T("[A-Za-z_]+[0-9]*[A-Za-z_]*"));
    from.Trim(true).Trim(false);
    to.Trim(true).Trim(false);
    if (!re.Matches(from) || !re.Matches(to))
    {
        cbMessageBox(_("Replacement tokens can only contain alphanumeric characters and underscores..."),
                    _("Error"), wxICON_ERROR);
        return false;
    }
    return true;
}


That's the cause of your problem.
Thanks!
I comment this code, and do it ok.
Now, class ATL_NO_VTABLE CHyperLinkImpl : public ATL::CWindowImpl< T, TBase, TWinTraits > is OK!

But, other headers, egg. string winuser.h, i don't know how to make it work.
WINUSERAPI
int
WINAPI
MessageBoxA(
    __in_opt HWND hWnd,
    __in_opt LPCSTR lpText,
    __in_opt LPCSTR lpCaption,
    __in UINT uType);
WINUSERAPI
int
WINAPI
MessageBoxW(
    __in_opt HWND hWnd,
    __in_opt LPCWSTR lpText,
    __in_opt LPCWSTR lpCaption,
    __in UINT uType);
#ifdef UNICODE
#define MessageBox  MessageBoxW
#else
#define MessageBox  MessageBoxA
#endif // !UNICODE

Loaden

I find: if the header file size more than 132KB, CC will not work!!
egg. Shlwapi.h,and CC work fine.

and if cut winuser.h from line 1 to line 8446, so, CC work fine.
Why?
need int to long long?

ollydbg

What do you mean by "CC will not work!!"?

It seems the Parser can't recognize the function argument like this:
MessageBoxA(
    __in_opt HWND hWnd,
    __in_opt LPCSTR lpText,
    __in_opt LPCSTR lpCaption,
    __in UINT uType);


The related implementation was in

void ParserThread::HandleFunction(const wxString& name, bool isOperator)

So, you can exam these code carefully to see the reason. :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

Quote from: ollydbg on June 01, 2009, 03:21:56 PM
MessageBoxA(
    __in_opt HWND hWnd,
    __in_opt LPCSTR lpText,
    __in_opt LPCSTR lpCaption,
    __in UINT uType);

Try replacing this "__in_opt" and alike with "empty", too... ;-) :lol: :lol: :lol:
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]

Loaden

Quote from: MortenMacFly on June 02, 2009, 08:08:11 AM
Quote from: ollydbg on June 01, 2009, 03:21:56 PM
MessageBoxA(
    __in_opt HWND hWnd,
    __in_opt LPCSTR lpText,
    __in_opt LPCSTR lpCaption,
    __in UINT uType);

Try replacing this "__in_opt" and alike with "empty", too... ;-) :lol: :lol: :lol:

It does not parameters question, it is the analysis of the header file is too large, it can not be fully analyzed with CC.

ollydbg

#9
Hi, all.

Today, I'm thinking how to refactor the replacement function in

In Tokenizer.cpp GetToken() function

   inline const wxString& ThisOrReplacement(const wxString& str) const
   {
       ConfigManagerContainer::StringToStringMap::const_iterator it = s_Replacements.find(str);
       if (it != s_Replacements.end())
           return it->second;
       return str;
   }


I think this function is some kind too simple. At least, it can do a search, then a replacement.

(I have exam the code in ctags and its manual, especially in it's code to do Macro replacement)
Here
http://ctags.sourceforge.net/ctags.html#OPERATIONAL%20DETAILS

Quote
−I identifier−list

Specifies a list of identifiers which are to be specially handled while parsing C and C++ source files. This option is specifically provided to handle special cases arising through the use of preprocessor macros.

When the identifiers listed are simple identifiers, these identifiers will be ignored during parsing of the source files.

If an identifier is suffixed with a '+' character, ctags will also ignore any parenthesis-enclosed argument list which may immediately follow the identifier in the source files.

If two identifiers are separated with the '=' character, the first identifiers is replaced by the second identifiers for parsing purposes.


So, at least, we can do the same thing like in Ctags.

In the option.c of Ctags source code, there are the related codes to doing identifier replacement.


/*  Determines whether or not "name" should be ignored, per the ignore list.
*/
extern boolean isIgnoreToken (
const char *const name, boolean *const pIgnoreParens,
const char **const replacement)
{
boolean result = FALSE;

if (Option.ignore != NULL)
{
const size_t nameLen = strlen (name);
unsigned int i;

if (pIgnoreParens != NULL)
*pIgnoreParens = FALSE;

for (i = 0  ;  i < stringListCount (Option.ignore)  ;  ++i)
{
vString *token = stringListItem (Option.ignore, i);

if (strncmp (vStringValue (token), name, nameLen) == 0)
{
const size_t tokenLen = vStringLength (token);

if (nameLen == tokenLen)
{
result = TRUE;
break;
}
else if (tokenLen == nameLen + 1  &&
vStringChar (token, tokenLen - 1) == '+')
{
result = TRUE;
if (pIgnoreParens != NULL)
*pIgnoreParens = TRUE;
break;
}
else if (vStringChar (token, nameLen) == '=')
{
if (replacement != NULL)
*replacement = vStringValue (token) + nameLen + 1;
break;
}
}
}
}
return result;
}


Here is what we can do in our Code completion code:


   inline const wxString& ThisOrReplacement(const wxString& str) const
   {
       ConfigManagerContainer::StringToStringMap::const_iterator it = s_Replacements.find(str);
       if (it != s_Replacements.end()){

           //Here we should example the "it->second"
           // if it is a "=new_token" string, the current_token should be replaced by "new_token"
           // if it is a "-" , the current string should be ignored, then we should return next token
           // if it is a "+",  the next "parenthesis-enclosed argument list" should be ignored
           // if it match any other pre-defined string grama, we will do other thing , eg, expand the current   token to two tokens...
           //......
           //return it->second;
       }
       return str;
   }



Any Comments?









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

@loaden:

I copy a large header from "Visual studio C++ header folder" which named "WINUSER.h" (232KB)

And I paste to the root of my test project folder, and renamed to "testWINUSER.h"

Then create a simple project


#include "testWINUSER.H"
int main()
{
    UserHandleGrantA  //code completion works fine!
    return 0;
}


And every thing works fine..  At least the last function declaration in that header file is


BOOL UserHandleGrantAccess(
    HANDLE hUserHandle,
    HANDLE hJob);


And code completion works fine! This means the totally 232K files were parsed, not break in the middle. :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.

blueshake

I do a patch for this ,class CHyperLinkImpl can be parsed correctly  now.
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

Quote from: blueshake on July 23, 2009, 01:35:01 PM
I do a patch for this ,class CHyperLinkImpl can be parsed correctly  now.
where can I find this patch??
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.


Loaden

#14
Thanks to ollydbg!
[removed non-english content]

It's seems have other reason, but not the file size.
It's maybe: max allowed matches. by default, it's be 16340, now i change the value to : 100000