From 8d926d7328ed630bdd724123e867b4e49cd7f495 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Thu, 20 Aug 2015 15:59:59 +0200 Subject: [PATCH] Moved some simple WinAPI/MFC-specific simplifications to windows.cfg --- cfg/windows.cfg | 5 +++++ lib/tokenize.cpp | 37 ------------------------------------- lib/tokenize.h | 7 ------- test/testtokenize.cpp | 15 --------------- 4 files changed, 5 insertions(+), 59 deletions(-) diff --git a/cfg/windows.cfg b/cfg/windows.cfg index 31f1889c6..517a6855f 100644 --- a/cfg/windows.cfg +++ b/cfg/windows.cfg @@ -1615,6 +1615,11 @@ HFONT CreateFont( + + + + + false diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 94b43e498..01cc1abc3 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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 diff --git a/lib/tokenize.h b/lib/tokenize.h index ba4a4be02..1baebc8e2 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -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) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 3ececd7c4..47f89858e 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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));