Moved some simple WinAPI/MFC-specific simplifications to windows.cfg

This commit is contained in:
PKEuS 2015-08-20 15:59:59 +02:00
parent cde7f48feb
commit 8d926d7328
4 changed files with 5 additions and 59 deletions

View File

@ -1615,6 +1615,11 @@ HFONT CreateFont(
<podtype name="ULARGE_INTEGER" sign="u" size="8"/>
<define name="INVALID_HANDLE_VALUE" value="0"/>
<define name="afx_msg" value=""/>
<define name="DEBUG_NEW" value="new"/>
<define name="DECLARE_MESSAGE_MAP()" value=""/>
<define name="DECLARE_DYNAMIC(x)" value=""/>
<define name="DECLARE_DYNAMIC_CLASS(x)" value=""/>
<define name="DECLARE_DYNCREATE(x)" value=""/>
<function name="CaptureStackBackTrace">
<noreturn>false</noreturn>
<arg nr="1">

View File

@ -2043,20 +2043,6 @@ void Tokenizer::simplifySQL()
}
}
void Tokenizer::simplifyDebugNew()
{
if (isC())
return;
if (!_settings->isWindowsPlatform())
return;
// convert Microsoft DEBUG_NEW macro to new
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (tok->str() == "DEBUG_NEW")
tok->str("new");
}
}
void Tokenizer::simplifyArrayAccessSyntax()
{
// 0[a] -> a[0]
@ -3368,9 +3354,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
// remove unnecessary member qualification..
removeUnnecessaryQualification();
// remove Microsoft MFC..
simplifyMicrosoftMFC();
// convert Microsoft memory functions
simplifyMicrosoftMemoryFunctions();
@ -3389,8 +3372,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
// #2449: syntax error: enum with typedef in it
checkForEnumsWithTypedef();
simplifyDebugNew();
// Remove __asm..
simplifyAsm();
@ -9518,24 +9499,6 @@ void Tokenizer::simplifyNamespaceStd()
}
// Remove Microsoft MFC 'DECLARE_MESSAGE_MAP()'
void Tokenizer::simplifyMicrosoftMFC()
{
if (isC())
return;
// skip if not Windows
if (!_settings->isWindowsPlatform())
return;
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (Token::simpleMatch(tok->next(), "DECLARE_MESSAGE_MAP ( )")) {
tok->deleteNext(3);
} else if (Token::Match(tok->next(), "DECLARE_DYNAMIC|DECLARE_DYNAMIC_CLASS|DECLARE_DYNCREATE ( %any% )")) {
tok->deleteNext(4);
}
}
}
void Tokenizer::simplifyMicrosoftMemoryFunctions()
{
// skip if not Windows

View File

@ -496,8 +496,6 @@ public:
void simplifyRoundCurlyParentheses();
void simplifyDebugNew();
void simplifySQL();
void checkForEnumsWithTypedef();
@ -659,11 +657,6 @@ private:
*/
void simplifyNamespaceStd();
/**
* Remove Microsoft MFC 'DECLARE_MESSAGE_MAP()'
*/
void simplifyMicrosoftMFC();
/**
* Convert Microsoft memory functions
* CopyMemory(dst, src, len) -> memcpy(dst, src, len)

View File

@ -349,7 +349,6 @@ private:
TEST_CASE(simplifyNamespaceStd);
TEST_CASE(microsoftMFC);
TEST_CASE(microsoftMemory);
TEST_CASE(borland);
@ -5750,20 +5749,6 @@ private:
ASSERT_EQUALS(expected14, tokenizeAndStringify(code14, false));
}
void microsoftMFC() {
const char code1[] = "class MyDialog : public CDialog { DECLARE_MESSAGE_MAP() private: CString text; };";
ASSERT_EQUALS("class MyDialog : public CDialog { private: CString text ; } ;", tokenizeAndStringify(code1,false,true,Settings::Win32A));
const char code2[] = "class MyDialog : public CDialog { DECLARE_DYNAMIC(MyDialog) private: CString text; };";
ASSERT_EQUALS("class MyDialog : public CDialog { private: CString text ; } ;", tokenizeAndStringify(code2,false,true,Settings::Win32A));
const char code3[] = "class MyDialog : public CDialog { DECLARE_DYNCREATE(MyDialog) private: CString text; };";
ASSERT_EQUALS("class MyDialog : public CDialog { private: CString text ; } ;", tokenizeAndStringify(code3,false,true,Settings::Win32A));
const char code4[] = "class MyDialog : public CDialog { DECLARE_DYNAMIC_CLASS(MyDialog) private: CString text; };";
ASSERT_EQUALS("class MyDialog : public CDialog { private: CString text ; } ;", tokenizeAndStringify(code4,false,true,Settings::Win32A));
}
void microsoftMemory() {
const char code1a[] = "void foo() { int a[10], b[10]; CopyMemory(a, b, sizeof(a)); }";
ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memcpy ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code1a,false,true,Settings::Win32A));