diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 020ddb220..c7aeeaa1d 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -6653,13 +6653,22 @@ void Tokenizer::simplifyPlatformTypes() } else if (tok->str() == "CHAR") tok->str("char"); - else if (Token::Match(tok, "DWORD")) + else if (Token::Match(tok, "DWORD|ULONG")) { tok->str("unsigned"); tok->insertToken("long"); } + else if (Token::Match(tok, "DWORD_PTR|ULONG_PTR|SIZE_T")) + { + tok->str("unsigned"); + tok->insertToken("long"); + if (_settings->platformType == Settings::Win64) + tok->insertToken("long"); + } else if (tok->str() == "FLOAT") tok->str("float"); + else if (tok->str() == "HRESULT") + tok->str("long"); else if (tok->str() == "INT64") { tok->str("long"); @@ -6667,6 +6676,12 @@ void Tokenizer::simplifyPlatformTypes() } else if (tok->str() == "LONG") tok->str("long"); + else if (tok->str() == "LONG_PTR") + { + tok->str("long"); + if (_settings->platformType == Settings::Win64) + tok->insertToken("long"); + } else if (Token::Match(tok, "LPBOOL|PBOOL")) { tok->str("int"); @@ -6711,7 +6726,7 @@ void Tokenizer::simplifyPlatformTypes() tok->str("char"); tok->insertToken("*"); } - else if (Token::Match(tok, "LPVOID|PVOID")) + else if (Token::Match(tok, "LPVOID|PVOID|HANDLE")) { tok->str("void"); tok->insertToken("*"); @@ -6729,10 +6744,16 @@ void Tokenizer::simplifyPlatformTypes() tok->str("unsigned"); tok->insertToken("int"); } - else if (tok->str() == "ULONG") + else if (tok->str() == "UINT_PTR") { tok->str("unsigned"); - tok->insertToken("long"); + if (_settings->platformType == Settings::Win64) + { + tok->insertToken("long"); + tok->insertToken("long"); + } + else + tok->insertToken("long"); } else if (Token::Match(tok, "USHORT|WORD")) { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 5f36fedce..49ac03386 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -5996,7 +5996,13 @@ private: "PSTR K;" "PCHAR L;" "LPVOID M;" - "PVOID N;"; + "PVOID N;" + "DWORD_PTR O;" + "ULONG_PTR P;" + "SIZE_T Q;" + "HRESULT R;" + "LONG_PTR S;" + "HANDLE T;"; const char expected[] = "unsigned int sizeof_short ; sizeof_short = 2 ; " "unsigned int sizeof_unsigned_short ; sizeof_unsigned_short = 2 ; " @@ -6051,7 +6057,13 @@ private: "char * K ; " "char * L ; " "void * M ; " - "void * N ;"; + "void * N ; " + "unsigned long O ; " + "unsigned long P ; " + "unsigned long Q ; " + "long R ; " + "long S ; " + "void * T ;"; ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Settings::Win32)); } @@ -6076,7 +6088,13 @@ private: "ssize_t b;" "ptrdiff_t c;" "intptr_t d;" - "uintptr_t e;"; + "uintptr_t e;" + "DWORD_PTR O;" + "ULONG_PTR P;" + "SIZE_T Q;" + "HRESULT R;" + "LONG_PTR S;" + "HANDLE T;"; const char expected[] = "unsigned int sizeof_short ; sizeof_short = 2 ; " "unsigned int sizeof_unsigned_short ; sizeof_unsigned_short = 2 ; " @@ -6096,7 +6114,13 @@ private: "long long b ; " "long long c ; " "long long d ; " - "unsigned long long e ;"; + "unsigned long long e ; " + "unsigned long long O ; " + "unsigned long long P ; " + "unsigned long long Q ; " + "long R ; " + "long long S ; " + "void * T ;"; ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Settings::Win64)); }