Moved some simple WinAPI/MFC-specific simplifications to windows.cfg
This commit is contained in:
parent
cde7f48feb
commit
8d926d7328
|
@ -1615,6 +1615,11 @@ HFONT CreateFont(
|
||||||
<podtype name="ULARGE_INTEGER" sign="u" size="8"/>
|
<podtype name="ULARGE_INTEGER" sign="u" size="8"/>
|
||||||
<define name="INVALID_HANDLE_VALUE" value="0"/>
|
<define name="INVALID_HANDLE_VALUE" value="0"/>
|
||||||
<define name="afx_msg" value=""/>
|
<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">
|
<function name="CaptureStackBackTrace">
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
<arg nr="1">
|
<arg nr="1">
|
||||||
|
|
|
@ -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()
|
void Tokenizer::simplifyArrayAccessSyntax()
|
||||||
{
|
{
|
||||||
// 0[a] -> a[0]
|
// 0[a] -> a[0]
|
||||||
|
@ -3368,9 +3354,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
// remove unnecessary member qualification..
|
// remove unnecessary member qualification..
|
||||||
removeUnnecessaryQualification();
|
removeUnnecessaryQualification();
|
||||||
|
|
||||||
// remove Microsoft MFC..
|
|
||||||
simplifyMicrosoftMFC();
|
|
||||||
|
|
||||||
// convert Microsoft memory functions
|
// convert Microsoft memory functions
|
||||||
simplifyMicrosoftMemoryFunctions();
|
simplifyMicrosoftMemoryFunctions();
|
||||||
|
|
||||||
|
@ -3389,8 +3372,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
// #2449: syntax error: enum with typedef in it
|
// #2449: syntax error: enum with typedef in it
|
||||||
checkForEnumsWithTypedef();
|
checkForEnumsWithTypedef();
|
||||||
|
|
||||||
simplifyDebugNew();
|
|
||||||
|
|
||||||
// Remove __asm..
|
// Remove __asm..
|
||||||
simplifyAsm();
|
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()
|
void Tokenizer::simplifyMicrosoftMemoryFunctions()
|
||||||
{
|
{
|
||||||
// skip if not Windows
|
// skip if not Windows
|
||||||
|
|
|
@ -496,8 +496,6 @@ public:
|
||||||
|
|
||||||
void simplifyRoundCurlyParentheses();
|
void simplifyRoundCurlyParentheses();
|
||||||
|
|
||||||
void simplifyDebugNew();
|
|
||||||
|
|
||||||
void simplifySQL();
|
void simplifySQL();
|
||||||
|
|
||||||
void checkForEnumsWithTypedef();
|
void checkForEnumsWithTypedef();
|
||||||
|
@ -659,11 +657,6 @@ private:
|
||||||
*/
|
*/
|
||||||
void simplifyNamespaceStd();
|
void simplifyNamespaceStd();
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove Microsoft MFC 'DECLARE_MESSAGE_MAP()'
|
|
||||||
*/
|
|
||||||
void simplifyMicrosoftMFC();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert Microsoft memory functions
|
* Convert Microsoft memory functions
|
||||||
* CopyMemory(dst, src, len) -> memcpy(dst, src, len)
|
* CopyMemory(dst, src, len) -> memcpy(dst, src, len)
|
||||||
|
|
|
@ -349,7 +349,6 @@ private:
|
||||||
|
|
||||||
TEST_CASE(simplifyNamespaceStd);
|
TEST_CASE(simplifyNamespaceStd);
|
||||||
|
|
||||||
TEST_CASE(microsoftMFC);
|
|
||||||
TEST_CASE(microsoftMemory);
|
TEST_CASE(microsoftMemory);
|
||||||
|
|
||||||
TEST_CASE(borland);
|
TEST_CASE(borland);
|
||||||
|
@ -5750,20 +5749,6 @@ private:
|
||||||
ASSERT_EQUALS(expected14, tokenizeAndStringify(code14, false));
|
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() {
|
void microsoftMemory() {
|
||||||
const char code1a[] = "void foo() { int a[10], b[10]; CopyMemory(a, b, sizeof(a)); }";
|
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));
|
ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memcpy ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code1a,false,true,Settings::Win32A));
|
||||||
|
|
Loading…
Reference in New Issue