Fixed #4977 (improve platform type tokenize performance)

This commit is contained in:
Robert Reif 2013-08-25 08:29:24 +02:00 committed by Daniel Marjamäki
parent b20f44cf6a
commit 3c6ca35e09
2 changed files with 36 additions and 35 deletions

View File

@ -5358,25 +5358,25 @@ void Tokenizer::simplifyPlatformTypes()
} }
if (Token::Match(tok, "size_t|uintptr_t")) { if (Token::Match(tok, "size_t|uintptr_t")) {
tok->str("unsigned"); tok->isUnsigned(true);
switch (type) { switch (type) {
case isLongLong: case isLongLong:
tok->insertToken("long"); tok->isLong(true);
tok->insertToken("long"); tok->str("long");
break; break;
case isLong : case isLong :
tok->insertToken("long"); tok->str("long");
break; break;
case isInt: case isInt:
tok->insertToken("int"); tok->str("int");
break; break;
} }
} else if (Token::Match(tok, "ssize_t|ptrdiff_t|intptr_t")) { } else if (Token::Match(tok, "ssize_t|ptrdiff_t|intptr_t")) {
switch (type) { switch (type) {
case isLongLong: case isLongLong:
tok->isLong(true);
tok->str("long"); tok->str("long");
tok->insertToken("long");
break; break;
case isLong : case isLong :
tok->str("long"); tok->str("long");
@ -5395,18 +5395,18 @@ void Tokenizer::simplifyPlatformTypes()
if (Token::Match(tok, "BOOL|INT|INT32|HFILE|LONG32")) if (Token::Match(tok, "BOOL|INT|INT32|HFILE|LONG32"))
tok->str("int"); tok->str("int");
else if (Token::Match(tok, "BOOLEAN|BYTE|UCHAR")) { else if (Token::Match(tok, "BOOLEAN|BYTE|UCHAR")) {
tok->str("unsigned"); tok->str("char");
tok->insertToken("char"); tok->isUnsigned(true);
} else if (tok->str() == "CHAR") } else if (tok->str() == "CHAR")
tok->str("char"); tok->str("char");
else if (Token::Match(tok, "DWORD|ULONG|COLORREF|LCID|LCTYPE|LGRPID")) { else if (Token::Match(tok, "DWORD|ULONG|COLORREF|LCID|LCTYPE|LGRPID")) {
tok->str("unsigned"); tok->str("long");
tok->insertToken("long"); tok->isUnsigned(true);
} else if (Token::Match(tok, "DWORD_PTR|ULONG_PTR|SIZE_T")) { } else if (Token::Match(tok, "DWORD_PTR|ULONG_PTR|SIZE_T")) {
tok->str("unsigned"); tok->str("long");
tok->insertToken("long"); tok->isUnsigned(true);
if (_settings->platformType == Settings::Win64) if (_settings->platformType == Settings::Win64)
tok->insertToken("long"); tok->isLong(true);
} else if (tok->str() == "FLOAT") } else if (tok->str() == "FLOAT")
tok->str("float"); tok->str("float");
else if (Token::Match(tok, "HRESULT|LONG")) else if (Token::Match(tok, "HRESULT|LONG"))
@ -5417,14 +5417,14 @@ void Tokenizer::simplifyPlatformTypes()
} else if (Token::Match(tok, "LONG_PTR|LPARAM|LRESULT|SSIZE_T")) { } else if (Token::Match(tok, "LONG_PTR|LPARAM|LRESULT|SSIZE_T")) {
tok->str("long"); tok->str("long");
if (_settings->platformType == Settings::Win64) if (_settings->platformType == Settings::Win64)
tok->insertToken("long"); tok->isLong(true);
} else if (Token::Match(tok, "LPBOOL|PBOOL")) { } else if (Token::Match(tok, "LPBOOL|PBOOL")) {
tok->str("int"); tok->str("int");
tok->insertToken("*"); tok->insertToken("*");
} else if (Token::Match(tok, "LPBYTE|PBOOLEAN|PBYTE|PUCHAR")) { } else if (Token::Match(tok, "LPBYTE|PBOOLEAN|PBYTE|PUCHAR")) {
tok->str("unsigned"); tok->isUnsigned(true);
tok->str("char");
tok->insertToken("*"); tok->insertToken("*");
tok->insertToken("char");
} else if (Token::Match(tok, "LPCSTR|PCSTR")) { } else if (Token::Match(tok, "LPCSTR|PCSTR")) {
tok->str("const"); tok->str("const");
tok->insertToken("*"); tok->insertToken("*");
@ -5434,9 +5434,9 @@ void Tokenizer::simplifyPlatformTypes()
tok->insertToken("*"); tok->insertToken("*");
tok->insertToken("void"); tok->insertToken("void");
} else if (Token::Match(tok, "LPDWORD|LPCOLORREF|PDWORD|PULONG")) { } else if (Token::Match(tok, "LPDWORD|LPCOLORREF|PDWORD|PULONG")) {
tok->str("unsigned"); tok->isUnsigned(true);
tok->str("long");
tok->insertToken("*"); tok->insertToken("*");
tok->insertToken("long");
} else if (Token::Match(tok, "LPINT|PINT")) { } else if (Token::Match(tok, "LPINT|PINT")) {
tok->str("int"); tok->str("int");
tok->insertToken("*"); tok->insertToken("*");
@ -5457,25 +5457,25 @@ void Tokenizer::simplifyPlatformTypes()
tok->insertToken("*"); tok->insertToken("*");
tok->insertToken("*"); tok->insertToken("*");
} else if (Token::Match(tok, "LPWORD|PWORD|PUSHORT")) { } else if (Token::Match(tok, "LPWORD|PWORD|PUSHORT")) {
tok->str("unsigned"); tok->isUnsigned(true);
tok->str("short");
tok->insertToken("*"); tok->insertToken("*");
tok->insertToken("short");
} else if (tok->str() == "SHORT") } else if (tok->str() == "SHORT")
tok->str("short"); tok->str("short");
else if (Token::Match(tok, "UINT|MMRESULT|SOCKET|ULONG32|UINT32|DWORD32")) { else if (Token::Match(tok, "UINT|MMRESULT|SOCKET|ULONG32|UINT32|DWORD32")) {
tok->str("unsigned"); tok->isUnsigned(true);
tok->insertToken("int"); tok->str("int");
} else if (Token::Match(tok, "UINT_PTR|WPARAM")) { } else if (Token::Match(tok, "UINT_PTR|WPARAM")) {
tok->str("unsigned"); tok->isUnsigned(true);
if (_settings->platformType == Settings::Win64) { if (_settings->platformType == Settings::Win64) {
tok->insertToken("long"); tok->str("long");
tok->insertToken("long"); tok->isLong(true);
} else { } else {
tok->insertToken("int"); tok->str("int");
} }
} else if (Token::Match(tok, "USHORT|WORD|ATOM|LANGID")) { } else if (Token::Match(tok, "USHORT|WORD|ATOM|LANGID")) {
tok->str("unsigned"); tok->isUnsigned(true);
tok->insertToken("short"); tok->str("short");
} else if (tok->str() == "VOID") } else if (tok->str() == "VOID")
tok->str("void"); tok->str("void");
else if (tok->str() == "TCHAR") { else if (tok->str() == "TCHAR") {
@ -5485,11 +5485,11 @@ void Tokenizer::simplifyPlatformTypes()
tok->str("wchar_t"); tok->str("wchar_t");
} }
} else if (tok->str() == "TBYTE") { } else if (tok->str() == "TBYTE") {
tok->str("unsigned"); tok->isUnsigned(true);
if (_settings->platformType == Settings::Win32A) if (_settings->platformType == Settings::Win32A)
tok->insertToken("short"); tok->str("short");
else else
tok->insertToken("char"); tok->str("char");
} else if (Token::Match(tok, "PTSTR|LPTSTR")) { } else if (Token::Match(tok, "PTSTR|LPTSTR")) {
if (_settings->platformType == Settings::Win32A) { if (_settings->platformType == Settings::Win32A) {
tok->str("char"); tok->str("char");
@ -5508,8 +5508,9 @@ void Tokenizer::simplifyPlatformTypes()
tok->insertToken("wchar_t"); tok->insertToken("wchar_t");
} }
} else if (Token::Match(tok, "ULONG64|DWORD64")) { } else if (Token::Match(tok, "ULONG64|DWORD64")) {
tok->str("unsigned"); tok->isUnsigned(true);
tok->insertToken("long"); tok->isLong(true);
tok->str("long");
} else if (tok->str() == "HALF_PTR") { } else if (tok->str() == "HALF_PTR") {
if (_settings->platformType == Settings::Win64) if (_settings->platformType == Settings::Win64)
tok->str("int"); tok->str("int");

View File

@ -7872,8 +7872,8 @@ private:
"wchar_t * pwchar ; " "wchar_t * pwchar ; "
"unsigned short * pushort ; " "unsigned short * pushort ; "
"unsigned short langid ; " "unsigned short langid ; "
"unsigned long dword64 ; " "unsigned long long dword64 ; "
"unsigned long ulong64 ; " "unsigned long long ulong64 ; "
"wchar_t * lpcwstr ; " "wchar_t * lpcwstr ; "
"const wchar_t * lpcwstr ;"; "const wchar_t * lpcwstr ;";