start adding conversions from common Windows types to standard types
This commit is contained in:
parent
958a53eaa8
commit
be660003ec
|
@ -52,16 +52,7 @@ Settings::Settings()
|
|||
posix = false;
|
||||
|
||||
// This assumes the code you are checking is for the same architecture this is compiled on.
|
||||
sizeof_bool = sizeof(bool);
|
||||
sizeof_short = sizeof(short);
|
||||
sizeof_int = sizeof(int);
|
||||
sizeof_long = sizeof(long);
|
||||
sizeof_long_long = sizeof(long long);
|
||||
sizeof_float = sizeof(float);
|
||||
sizeof_double = sizeof(double);
|
||||
sizeof_long_double = sizeof(long double);
|
||||
sizeof_size_t = sizeof(size_t);
|
||||
sizeof_pointer = sizeof(void *);
|
||||
platform(Host);
|
||||
}
|
||||
|
||||
std::string Settings::addEnabled(const std::string &str)
|
||||
|
@ -144,8 +135,20 @@ bool Settings::platform(PlatformType type)
|
|||
switch (type)
|
||||
{
|
||||
case Host: // same as system this code was compile on
|
||||
platformType = Host;
|
||||
sizeof_bool = sizeof(bool);
|
||||
sizeof_short = sizeof(short);
|
||||
sizeof_int = sizeof(int);
|
||||
sizeof_long = sizeof(long);
|
||||
sizeof_long_long = sizeof(long long);
|
||||
sizeof_float = sizeof(float);
|
||||
sizeof_double = sizeof(double);
|
||||
sizeof_long_double = sizeof(long double);
|
||||
sizeof_size_t = sizeof(size_t);
|
||||
sizeof_pointer = sizeof(void *);
|
||||
return true;
|
||||
case Win32:
|
||||
platformType = Win32;
|
||||
sizeof_bool = 1; // 4 in Visual C++ 4.2
|
||||
sizeof_short = 2;
|
||||
sizeof_int = 4;
|
||||
|
@ -158,6 +161,7 @@ bool Settings::platform(PlatformType type)
|
|||
sizeof_pointer = 4;
|
||||
return true;
|
||||
case Win64:
|
||||
platformType = Win64;
|
||||
sizeof_bool = 1;
|
||||
sizeof_short = 2;
|
||||
sizeof_int = 4;
|
||||
|
@ -170,6 +174,7 @@ bool Settings::platform(PlatformType type)
|
|||
sizeof_pointer = 8;
|
||||
return true;
|
||||
case Unix32:
|
||||
platformType = Unix32;
|
||||
sizeof_bool = 1;
|
||||
sizeof_short = 2;
|
||||
sizeof_int = 4;
|
||||
|
@ -182,6 +187,7 @@ bool Settings::platform(PlatformType type)
|
|||
sizeof_pointer = 4;
|
||||
return true;
|
||||
case Unix64:
|
||||
platformType = Unix64;
|
||||
sizeof_bool = 1;
|
||||
sizeof_short = 2;
|
||||
sizeof_int = 4;
|
||||
|
|
|
@ -212,6 +212,9 @@ public:
|
|||
Unix64
|
||||
};
|
||||
|
||||
/** platform type */
|
||||
PlatformType platformType;
|
||||
|
||||
/** set the platform type for predefined platforms */
|
||||
bool platform(PlatformType type);
|
||||
|
||||
|
|
|
@ -6638,6 +6638,56 @@ void Tokenizer::simplifyPlatformTypes()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_settings->platformType == Settings::Win32 ||
|
||||
_settings->platformType == Settings::Win64)
|
||||
{
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
if (Token::Match(tok, "BOOL|INT|INT32"))
|
||||
tok->str("int");
|
||||
else if (Token::Match(tok, "BOOLEAN|BYTE|UCHAR"))
|
||||
{
|
||||
tok->str("unsigned");
|
||||
tok->insertToken("char");
|
||||
}
|
||||
else if (tok->str() == "CHAR")
|
||||
tok->str("char");
|
||||
else if (Token::Match(tok, "DWORD"))
|
||||
{
|
||||
tok->str("unsigned");
|
||||
tok->insertToken("long");
|
||||
}
|
||||
else if (tok->str() == "FLOAT")
|
||||
tok->str("float");
|
||||
else if (tok->str() == "INT64")
|
||||
{
|
||||
tok->str("long");
|
||||
tok->insertToken("long");
|
||||
}
|
||||
else if (tok->str() == "LONG")
|
||||
tok->str("long");
|
||||
else if (tok->str() == "SHORT")
|
||||
tok->str("short");
|
||||
else if (tok->str() == "UINT")
|
||||
{
|
||||
tok->str("unsigned");
|
||||
tok->insertToken("int");
|
||||
}
|
||||
else if (tok->str() == "ULONG")
|
||||
{
|
||||
tok->str("unsigned");
|
||||
tok->insertToken("long");
|
||||
}
|
||||
else if (Token::Match(tok, "USHORT|WORD"))
|
||||
{
|
||||
tok->str("unsigned");
|
||||
tok->insertToken("short");
|
||||
}
|
||||
else if (tok->str() == "VOID")
|
||||
tok->str("void");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Tokenizer::simplifyStdType()
|
||||
|
|
|
@ -5961,7 +5961,25 @@ private:
|
|||
"ssize_t b;"
|
||||
"ptrdiff_t c;"
|
||||
"intptr_t d;"
|
||||
"uintptr_t e;";
|
||||
"uintptr_t e;"
|
||||
"BOOL f;"
|
||||
"BOOLEAN g;"
|
||||
"BYTE h;"
|
||||
"CHAR i;"
|
||||
"DWORD j;"
|
||||
"FLOAT k;"
|
||||
"INT l;"
|
||||
"INT32 m;"
|
||||
"INT64 n;"
|
||||
"LONG o;"
|
||||
"SHORT p;"
|
||||
"UCHAR q;"
|
||||
"UINT r;"
|
||||
"ULONG s;"
|
||||
"USHORT t;"
|
||||
"WORD u;"
|
||||
"VOID * v;";
|
||||
|
||||
|
||||
const char expected[] = "unsigned int sizeof_short ; sizeof_short = 2 ; "
|
||||
"unsigned int sizeof_unsigned_short ; sizeof_unsigned_short = 2 ; "
|
||||
|
@ -5981,7 +5999,24 @@ private:
|
|||
"long b ; "
|
||||
"long c ; "
|
||||
"long d ; "
|
||||
"unsigned long e ;";
|
||||
"unsigned long e ; "
|
||||
"int f ; "
|
||||
"unsigned char g ; "
|
||||
"unsigned char h ; "
|
||||
"char i ; "
|
||||
"unsigned long j ; "
|
||||
"float k ; "
|
||||
"int l ; "
|
||||
"int m ; "
|
||||
"long long n ; "
|
||||
"long o ; "
|
||||
"short p ; "
|
||||
"unsigned char q ; "
|
||||
"unsigned int r ; "
|
||||
"unsigned long s ; "
|
||||
"unsigned short t ; "
|
||||
"unsigned short u ; "
|
||||
"void * v ;";
|
||||
|
||||
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Settings::Win32));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue