From 42f709c09d90471c376156b2b93875572d44684f Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Tue, 21 Oct 2014 06:11:19 +0200 Subject: [PATCH] Fixed #6229 (Move Windows builtin types __intXX to library) --- cfg/windows.cfg | 21 +++++++++++++++++++++ lib/tokenize.cpp | 23 ++++------------------- test/testtokenize.cpp | 26 +++++++++++++------------- 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/cfg/windows.cfg b/cfg/windows.cfg index 0297336d3..18aff67d5 100644 --- a/cfg/windows.cfg +++ b/cfg/windows.cfg @@ -1,5 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 5b6808d2c..0204b3b9c 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5662,8 +5662,6 @@ void Tokenizer::simplifyPlatformTypes() for (Token *tok = list.front(); tok; tok = tok->next()) { if (tok->type() != Token::eType && tok->type() != Token::eName) continue; - if (!tok->isUpperCaseName()) // All WinAPI types are uppercase. Reduce number of Token::Match calls by this condition. - continue; const Library::PlatformType * const platformtype = _settings->library.platform_type(tok->str(), platform_type); @@ -5712,14 +5710,14 @@ void Tokenizer::simplifyStdType() { for (Token *tok = list.front(); tok; tok = tok->next()) { // long unsigned => unsigned long - if (Token::Match(tok, "char|short|int|long|__int8|__int16|__int32|__int64 unsigned|signed")) { + if (Token::Match(tok, "char|short|int|long unsigned|signed")) { bool isUnsigned = tok->next()->str() == "unsigned"; tok->deleteNext(); tok->isUnsigned(isUnsigned); tok->isSigned(!isUnsigned); } - else if (!Token::Match(tok, "unsigned|signed|char|short|int|long|__int8|__int16|__int32|__int64")) + else if (!Token::Match(tok, "unsigned|signed|char|short|int|long")) continue; // check if signed or unsigned specified @@ -5727,7 +5725,7 @@ void Tokenizer::simplifyStdType() bool isUnsigned = tok->str() == "unsigned"; // unsigned i => unsigned int i - if (!Token::Match(tok->next(), "char|short|int|long|__int8|__int16|__int32|__int64")) + if (!Token::Match(tok->next(), "char|short|int|long")) tok->str("int"); else tok->deleteThis(); @@ -5735,20 +5733,7 @@ void Tokenizer::simplifyStdType() tok->isSigned(!isUnsigned); } - if (tok->str() == "__int8") { - tok->originalName(tok->str()); - tok->str("char"); - } else if (tok->str() == "__int16") { - tok->originalName(tok->str()); - tok->str("short"); - } else if (tok->str() == "__int32") { - tok->originalName(tok->str()); - tok->str("int"); - } else if (tok->str() == "__int64") { - tok->originalName(tok->str()); - tok->str("long"); - tok->isLong(true); - } else if (tok->str() == "int") { + if (tok->str() == "int") { if (tok->strAt(1) == "long") { tok->str("long"); tok->deleteNext(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 2eb9447aa..85cc3b7c8 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -5459,16 +5459,16 @@ private: ASSERT_EQUALS("struct A { long x ; } ;", tokenizeAndStringify(code5,false)); const char code6[] = "struct A { __int8 x : 3; };"; - ASSERT_EQUALS("struct A { char x ; } ;", tokenizeAndStringify(code6,false)); + ASSERT_EQUALS("struct A { char x ; } ;", tokenizeAndStringifyWindows(code6,false, true, Settings::Win32A)); const char code7[] = "struct A { __int16 x : 3; };"; - ASSERT_EQUALS("struct A { short x ; } ;", tokenizeAndStringify(code7,false)); + ASSERT_EQUALS("struct A { short x ; } ;", tokenizeAndStringifyWindows(code7,false, true, Settings::Win32A)); const char code8[] = "struct A { __int32 x : 3; };"; - ASSERT_EQUALS("struct A { int x ; } ;", tokenizeAndStringify(code8,false)); + ASSERT_EQUALS("struct A { int x ; } ;", tokenizeAndStringifyWindows(code8,false, true, Settings::Win32A)); const char code9[] = "struct A { __int64 x : 3; };"; - ASSERT_EQUALS("struct A { long long x ; } ;", tokenizeAndStringify(code9,false)); + ASSERT_EQUALS("struct A { long long x ; } ;", tokenizeAndStringifyWindows(code9,false, true, Settings::Win32A)); const char code10[] = "struct A { unsigned char x : 3; };"; ASSERT_EQUALS("struct A { unsigned char x ; } ;", tokenizeAndStringify(code10,false)); @@ -5483,16 +5483,16 @@ private: ASSERT_EQUALS("struct A { unsigned long x ; } ;", tokenizeAndStringify(code13,false)); const char code14[] = "struct A { unsigned __int8 x : 3; };"; - ASSERT_EQUALS("struct A { unsigned char x ; } ;", tokenizeAndStringify(code14,false)); + ASSERT_EQUALS("struct A { unsigned char x ; } ;", tokenizeAndStringifyWindows(code14,false, true, Settings::Win32A)); const char code15[] = "struct A { unsigned __int16 x : 3; };"; - ASSERT_EQUALS("struct A { unsigned short x ; } ;", tokenizeAndStringify(code15,false)); + ASSERT_EQUALS("struct A { unsigned short x ; } ;", tokenizeAndStringifyWindows(code15,false, true, Settings::Win32A)); const char code16[] = "struct A { unsigned __int32 x : 3; };"; - ASSERT_EQUALS("struct A { unsigned int x ; } ;", tokenizeAndStringify(code16,false)); + ASSERT_EQUALS("struct A { unsigned int x ; } ;", tokenizeAndStringifyWindows(code16,false, true, Settings::Win32A)); const char code17[] = "struct A { unsigned __int64 x : 3; };"; - ASSERT_EQUALS("struct A { unsigned long long x ; } ;", tokenizeAndStringify(code17,false)); + ASSERT_EQUALS("struct A { unsigned long long x ; } ;", tokenizeAndStringifyWindows(code17,false, true, Settings::Win32A)); const char code18[] = "struct A { signed char x : 3; };"; ASSERT_EQUALS("struct A { signed char x ; } ;", tokenizeAndStringify(code18,false)); @@ -5504,19 +5504,19 @@ private: ASSERT_EQUALS("struct A { signed int x ; } ;", tokenizeAndStringify(code20,false)); const char code21[] = "struct A { signed long x : 3; };"; - ASSERT_EQUALS("struct A { signed long x ; } ;", tokenizeAndStringify(code21,false)); + ASSERT_EQUALS("struct A { signed long x ; } ;", tokenizeAndStringifyWindows(code21,false)); const char code22[] = "struct A { signed __int8 x : 3; };"; - ASSERT_EQUALS("struct A { signed char x ; } ;", tokenizeAndStringify(code22,false)); + ASSERT_EQUALS("struct A { signed char x ; } ;", tokenizeAndStringifyWindows(code22,false, true, Settings::Win32A)); const char code23[] = "struct A { signed __int16 x : 3; };"; - ASSERT_EQUALS("struct A { signed short x ; } ;", tokenizeAndStringify(code23,false)); + ASSERT_EQUALS("struct A { signed short x ; } ;", tokenizeAndStringifyWindows(code23,false, true, Settings::Win32A)); const char code24[] = "struct A { signed __int32 x : 3; };"; - ASSERT_EQUALS("struct A { signed int x ; } ;", tokenizeAndStringify(code24,false)); + ASSERT_EQUALS("struct A { signed int x ; } ;", tokenizeAndStringifyWindows(code24,false, true, Settings::Win32A)); const char code25[] = "struct A { signed __int64 x : 3; };"; - ASSERT_EQUALS("struct A { signed long long x ; } ;", tokenizeAndStringify(code25,false)); + ASSERT_EQUALS("struct A { signed long long x ; } ;", tokenizeAndStringifyWindows(code25,false, true, Settings::Win32A)); } void bitfields2() {