I just debugged the code, and I see we get a failure when expanding the macro usage of:
STDMETHOD(QueryInterface)
Here have a code snippet:
bool Tokenizer::GetMacroExpandedText(const Token* tk, wxString& expandedText)
{
// e.g. "#define AAA AAA" and usage "AAA(x)"
if (!tk || tk->m_Name == tk->m_FullType)
return false;
// sanity check if we have such macro definition that #define AAA(x,y) x+y+AAA
// if a macro name exists in its definition, it will cause a infinite expansion loop
if (tk->m_FullType.Find(tk->m_Name) != wxNOT_FOUND)
return false;
Here, the macro definition token tk is:
[debug]> p *tk
[debug]$3 = {m_FullType = L"virtual HRESULT STDMETHODCALLTYPE m", m_BaseType = L"m", m_Name = L"STDMETHOD", m_Args = L"(m)",
Now, I see that m_FullType contains the m_Name, so we just stop expansion, and return false to avoid infinite recursive call
It looks like this case, we should still expand, also we should improve how macro expansion works in our CC's parser.
EDIT:The reason of this issue is that currently, expansion of macro usage just do some text replacement, but we never consider the text as a token serials. So, the improvement should be use the Tokenizer::DoGetToken() function with tsReadRawExpression bit set, so that we get a raw token sequence(we can store them in a wxArrayString), and later, we need to compare each element. Thus, we need to remove all the KMP related functions, since they are generally search for the plain text, not the token sequence.