Rename Unspecified platform type to Native

This commit is contained in:
Daniel Marjamäki 2016-01-01 16:39:41 +01:00
parent 3bd5a4d10e
commit f5715c1496
9 changed files with 62 additions and 47 deletions

View File

@ -55,7 +55,7 @@ Settings::Settings()
#elif defined(_WIN32)
platform(Win32A);
#else
platform(Unspecified);
platform(Native);
#endif
}
@ -139,7 +139,21 @@ const std::string &Settings::append() const
bool Settings::platform(PlatformType type)
{
switch (type) {
case Unspecified: // same as system this code was compile on
case Unspecified:
platformType = type;
sizeof_bool = 1;
sizeof_short = 1;
sizeof_int = 1;
sizeof_long = 1;
sizeof_long_long = 1;
sizeof_float = 1;
sizeof_double = 1;
sizeof_long_double = 1;
sizeof_wchar_t = 1;
sizeof_size_t = 1;
sizeof_pointer = 1;
return true;
case Native: // same as system this code was compile on
platformType = type;
sizeof_bool = sizeof(bool);
sizeof_short = sizeof(short);

View File

@ -254,7 +254,8 @@ public:
unsigned int sizeof_pointer;
enum PlatformType {
Unspecified, // whatever system this code was compiled on
Unspecified, // No platform specified
Native, // whatever system this code was compiled on
Win32A,
Win32W,
Win64,

View File

@ -62,7 +62,7 @@ private:
TEST_CASE(testAstType); // #7014
}
void check(const char code[], bool inconclusive = false, bool portability = false, Settings::PlatformType platform = Settings::Unspecified) {
void check(const char code[], bool inconclusive = false, bool portability = false, Settings::PlatformType platform = Settings::Native) {
// Clear the error buffer..
errout.str("");

View File

@ -103,7 +103,7 @@ private:
TEST_CASE(templateNamePosition);
}
std::string tok(const char code[], bool simplify = true, bool debugwarnings = false, Settings::PlatformType type = Settings::Unspecified) {
std::string tok(const char code[], bool simplify = true, bool debugwarnings = false, Settings::PlatformType type = Settings::Native) {
errout.str("");
settings.debugwarnings = debugwarnings;

View File

@ -271,7 +271,7 @@ private:
TEST_CASE(simplifyOverride); // ticket #5069
}
std::string tok(const char code[], bool simplify = true, Settings::PlatformType type = Settings::Unspecified) {
std::string tok(const char code[], bool simplify = true, Settings::PlatformType type = Settings::Native) {
errout.str("");
settings0.platform(type);
@ -286,7 +286,7 @@ private:
return tokenizer.tokens()->stringifyList(0, !simplify);
}
std::string tokWithWindows(const char code[], bool simplify = true, Settings::PlatformType type = Settings::Unspecified) {
std::string tokWithWindows(const char code[], bool simplify = true, Settings::PlatformType type = Settings::Native) {
errout.str("");
settings_windows.platform(type);
@ -975,7 +975,7 @@ private:
void sizeof7() {
const char code[] = ";INT32 i[10];\n"
"sizeof(i[0]);\n";
ASSERT_EQUALS("; INT32 i [ 10 ] ; sizeof ( i [ 0 ] ) ;", tok(code, true, Settings::Unspecified));
ASSERT_EQUALS("; INT32 i [ 10 ] ; sizeof ( i [ 0 ] ) ;", tok(code, true, Settings::Native));
ASSERT_EQUALS("; int i [ 10 ] ; 4 ;", tokWithWindows(code, true, Settings::Win32A));
}

View File

@ -169,7 +169,7 @@ private:
TEST_CASE(simplifyTypedefShadow); // #4445 - shadow variable
}
std::string tok(const char code[], bool simplify = true, Settings::PlatformType type = Settings::Unspecified, bool debugwarnings = true) {
std::string tok(const char code[], bool simplify = true, Settings::PlatformType type = Settings::Native, bool debugwarnings = true) {
errout.str("");
settings0.inconclusive = true;
@ -494,7 +494,7 @@ private:
"};";
// Tokenize and check output..
tok(code, true, Settings::Unspecified, false);
tok(code, true, Settings::Native, false);
ASSERT_EQUALS("", errout.str());
}
@ -1700,7 +1700,7 @@ private:
" Foo b(0);\n"
" return b > Foo(10);\n"
"}";
const std::string actual(tok(code, true, Settings::Unspecified, false));
const std::string actual(tok(code, true, Settings::Native, false));
ASSERT_EQUALS("int main ( ) { BAR < int > b ( 0 ) ; return b > BAR < int > ( 10 ) ; }", actual);
ASSERT_EQUALS("", errout.str());
}
@ -1856,14 +1856,14 @@ private:
void simplifyTypedef75() { // ticket #2426
const char code[] = "typedef _Packed struct S { long l; };";
ASSERT_EQUALS("", tok(code, true, Settings::Unspecified, false));
ASSERT_EQUALS("", tok(code, true, Settings::Native, false));
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedef76() { // ticket #2453 segmentation fault
const char code[] = "void f1(typedef int x) {}";
const char expected[] = "void f1 ( typedef int x ) { }";
ASSERT_EQUALS(expected, tok(code, true, Settings::Unspecified, false));
ASSERT_EQUALS(expected, tok(code, true, Settings::Native, false));
ASSERT_EQUALS("", errout.str());
}
@ -2182,7 +2182,7 @@ private:
"public: "
"expression_error :: error_code * f ; "
"} ;";
ASSERT_EQUALS(expected, tok(code, true, Settings::Unspecified, false));
ASSERT_EQUALS(expected, tok(code, true, Settings::Native, false));
ASSERT_EQUALS("", errout.str());
}
@ -2355,7 +2355,7 @@ private:
"} ; "
"} "
"}";
ASSERT_EQUALS(expected, tok(code, true, Settings::Unspecified, false));
ASSERT_EQUALS(expected, tok(code, true, Settings::Native, false));
ASSERT_EQUALS("", errout.str());
}
@ -2704,7 +2704,7 @@ private:
"C * f5 ; " // this gets simplified to a regular pointer
"C * f6 ; " // this gets simplified to a regular pointer
"C * f7 ;"; // this gets simplified to a regular pointer
ASSERT_EQUALS(expected, tok(code, true, Settings::Unspecified, false));
ASSERT_EQUALS(expected, tok(code, true, Settings::Native, false));
ASSERT_EQUALS("", errout.str());
}
@ -2733,7 +2733,7 @@ private:
"const C * f5 ; " // this gets simplified to a regular pointer
"const C * f6 ; " // this gets simplified to a regular pointer
"const C * f7 ;"; // this gets simplified to a regular pointer
ASSERT_EQUALS(expected, tok(code, true, Settings::Unspecified, false));
ASSERT_EQUALS(expected, tok(code, true, Settings::Native, false));
ASSERT_EQUALS("", errout.str());
}
@ -2761,7 +2761,7 @@ private:
"const C * f5 ; " // this gets simplified to a regular pointer
"const C * f6 ; " // this gets simplified to a regular pointer
"const C * f7 ;"; // this gets simplified to a regular pointer
ASSERT_EQUALS(expected, tok(code, true, Settings::Unspecified, false));
ASSERT_EQUALS(expected, tok(code, true, Settings::Native, false));
ASSERT_EQUALS("", errout.str());
}
@ -2789,7 +2789,7 @@ private:
"C * * f5 ; " // this gets simplified to a regular pointer
"C * * f6 ; " // this gets simplified to a regular pointer
"C * * f7 ;"; // this gets simplified to a regular pointer
ASSERT_EQUALS(expected, tok(code, true, Settings::Unspecified, false));
ASSERT_EQUALS(expected, tok(code, true, Settings::Native, false));
ASSERT_EQUALS("", errout.str());
}
@ -2817,7 +2817,7 @@ private:
"const C * * f5 ; " // this gets simplified to a regular pointer
"const C * * f6 ; " // this gets simplified to a regular pointer
"const C * * f7 ;"; // this gets simplified to a regular pointer
ASSERT_EQUALS(expected, tok(code, true, Settings::Unspecified, false));
ASSERT_EQUALS(expected, tok(code, true, Settings::Native, false));
ASSERT_EQUALS("", errout.str());
}
@ -2846,7 +2846,7 @@ private:
"const C * * f5 ; " // this gets simplified to a regular pointer
"const C * * f6 ; " // this gets simplified to a regular pointer
"const C * * f7 ;"; // this gets simplified to a regular pointer
ASSERT_EQUALS(expected, tok(code, true, Settings::Unspecified, false));
ASSERT_EQUALS(expected, tok(code, true, Settings::Native, false));
ASSERT_EQUALS("", errout.str());
}
}
@ -2991,7 +2991,7 @@ private:
"B :: C * f2 ; "
"B :: C * f3 ; "
"B :: C * f4 ;";
ASSERT_EQUALS(expected, tok(code, true, Settings::Unspecified, false));
ASSERT_EQUALS(expected, tok(code, true, Settings::Native, false));
ASSERT_EQUALS("", errout.str());
}
@ -3029,7 +3029,7 @@ private:
"A :: B :: C * f2 ; "
"A :: B :: C * f3 ; "
"A :: B :: C * f4 ;";
ASSERT_EQUALS(expected, tok(code, true, Settings::Unspecified, false));
ASSERT_EQUALS(expected, tok(code, true, Settings::Native, false));
ASSERT_EQUALS("", errout.str());
}
}

View File

@ -463,7 +463,7 @@ private:
TEST_CASE(noreturn); // #5783
}
std::string tokenizeAndStringify(const char code[], bool simplify = false, bool expand = true, Settings::PlatformType platform = Settings::Unspecified, const char* filename = "test.cpp", bool cpp11 = true) {
std::string tokenizeAndStringify(const char code[], bool simplify = false, bool expand = true, Settings::PlatformType platform = Settings::Native, const char* filename = "test.cpp", bool cpp11 = true) {
errout.str("");
settings1.debugwarnings = true;
@ -493,7 +493,7 @@ private:
return "";
}
std::string tokenizeAndStringifyWindows(const char code[], bool simplify = false, bool expand = true, Settings::PlatformType platform = Settings::Unspecified, const char* filename = "test.cpp", bool cpp11 = true) {
std::string tokenizeAndStringifyWindows(const char code[], bool simplify = false, bool expand = true, Settings::PlatformType platform = Settings::Native, const char* filename = "test.cpp", bool cpp11 = true) {
errout.str("");
settings_windows.debugwarnings = true;
@ -2444,7 +2444,7 @@ private:
"cin >> x ;\n"
"return x ;\n"
"}";
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Settings::Unspecified, "test.cpp"));
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Settings::Native, "test.cpp"));
}
{
@ -2453,7 +2453,7 @@ private:
"cin >> 0 ;\n"
"return 0 ;\n"
"}";
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Settings::Unspecified, "test.c"));
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Settings::Native, "test.c"));
}
}
@ -2467,7 +2467,7 @@ private:
"int x ; x = 0 ;\n"
"cin >> std :: hex >> x ;\n"
"}";
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Settings::Unspecified, "test.cpp"));
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Settings::Native, "test.cpp"));
}
void simplifyKnownVariables48() {
@ -2480,7 +2480,7 @@ private:
"int i ;\n"
"for ( i = 0 ; ( i < sz ) && ( sz > 3 ) ; ++ i ) { }\n"
"}";
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Settings::Unspecified, "test.c"));
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Settings::Native, "test.c"));
}
void simplifyKnownVariables49() { // #3691
@ -2496,7 +2496,7 @@ private:
"case 2 : ; x = sz ; break ;\n"
"}\n"
"}";
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Settings::Unspecified, "test.c"));
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Settings::Native, "test.c"));
}
void simplifyKnownVariables50() { // #4066
@ -3445,8 +3445,8 @@ private:
ASSERT_EQUALS(expected, tokenizeAndStringify(code,true));
}
ASSERT_EQUALS("( a == nullptr )", tokenizeAndStringify("(a==nullptr)", false, false, Settings::Unspecified, "test.c"));
ASSERT_EQUALS("( a == 0 )", tokenizeAndStringify("(a==nullptr)", false, false, Settings::Unspecified, "test.cpp"));
ASSERT_EQUALS("( a == nullptr )", tokenizeAndStringify("(a==nullptr)", false, false, Settings::Native, "test.c"));
ASSERT_EQUALS("( a == 0 )", tokenizeAndStringify("(a==nullptr)", false, false, Settings::Native, "test.cpp"));
ASSERT_EQUALS("if ( p == 0 )", tokenizeAndStringify("if (p==NULL)"));
ASSERT_EQUALS("f ( NULL ) ;", tokenizeAndStringify("f(NULL);"));
@ -3764,7 +3764,7 @@ private:
void vardecl14() {
const char code[] = "::std::tr1::shared_ptr<int> pNum1, pNum2;\n";
ASSERT_EQUALS(":: std :: tr1 :: shared_ptr < int > pNum1 ; :: std :: tr1 :: shared_ptr < int > pNum2 ;", tokenizeAndStringify(code, false, false, Settings::Unspecified, "test.cpp", false));
ASSERT_EQUALS(":: std :: tr1 :: shared_ptr < int > pNum1 ; :: std :: tr1 :: shared_ptr < int > pNum2 ;", tokenizeAndStringify(code, false, false, Settings::Native, "test.cpp", false));
}
void vardecl15() {
@ -3969,7 +3969,7 @@ private:
void vardecl26() { // #5907
const char code[] = "extern int *new, obj, player;";
const char expected[] = "extern int * new ; extern int obj ; extern int player ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code, false, true, Settings::Unspecified, "test.c"));
ASSERT_EQUALS(expected, tokenizeAndStringify(code, false, true, Settings::Native, "test.c"));
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
}
@ -4589,11 +4589,11 @@ private:
// Pointer to standard type
ASSERT_EQUALS("char buf [ 100 ] ; readlink ( path , buf , 99 ) ;",
tokenizeAndStringify("char buf[100] ; readlink(path, &buf[0], 99);",
false, true, Settings::Unspecified, "test.c"));
false, true, Settings::Native, "test.c"));
// Simplification of unknown type - C only
ASSERT_EQUALS("foo data [ 100 ] ; something ( foo ) ;",
tokenizeAndStringify("foo data[100]; something(&foo[0]);", false, true, Settings::Unspecified, "test.c"));
tokenizeAndStringify("foo data[100]; something(&foo[0]);", false, true, Settings::Native, "test.c"));
// C++: No pointer simplification
ASSERT_EQUALS("foo data [ 100 ] ; something ( & foo [ 0 ] ) ;",
@ -5390,12 +5390,12 @@ private:
static const char code9[] = "using namespace std;\n"
"tr1::function <void(int)> f;";
ASSERT_EQUALS("tr1 :: function < void ( int ) > f ;", tokenizeAndStringify(code9, false, true, Settings::Unspecified, "test.cpp", false));
ASSERT_EQUALS("std :: function < void ( int ) > f ;", tokenizeAndStringify(code9, false, true, Settings::Unspecified, "test.cpp", true));
ASSERT_EQUALS("tr1 :: function < void ( int ) > f ;", tokenizeAndStringify(code9, false, true, Settings::Native, "test.cpp", false));
ASSERT_EQUALS("std :: function < void ( int ) > f ;", tokenizeAndStringify(code9, false, true, Settings::Native, "test.cpp", true));
static const char code10[] = "std::tr1::function <void(int)> f;";
ASSERT_EQUALS("std :: tr1 :: function < void ( int ) > f ;", tokenizeAndStringify(code10, false, true, Settings::Unspecified, "test.cpp", false));
ASSERT_EQUALS("std :: function < void ( int ) > f ;", tokenizeAndStringify(code10, false, true, Settings::Unspecified, "test.cpp", true));
ASSERT_EQUALS("std :: tr1 :: function < void ( int ) > f ;", tokenizeAndStringify(code10, false, true, Settings::Native, "test.cpp", false));
ASSERT_EQUALS("std :: function < void ( int ) > f ;", tokenizeAndStringify(code10, false, true, Settings::Native, "test.cpp", true));
// #4042 (Do not add 'std ::' to variables)
static const char code11[] = "using namespace std;\n"
@ -5678,7 +5678,7 @@ private:
"operator ( ) ; "
"}";
ASSERT_EQUALS(result, tokenizeAndStringify(code, /*simplify=*/false, /*expand=*/true, /*platform=*/Settings::Unspecified, "test.c"));
ASSERT_EQUALS(result, tokenizeAndStringify(code, /*simplify=*/false, /*expand=*/true, /*platform=*/Settings::Native, "test.c"));
}
void simplifyOperatorName2() {
@ -7930,13 +7930,13 @@ private:
void simplifyDeprecated() {
ASSERT_EQUALS("int f ( ) ;",
tokenizeAndStringify("[[deprecated]] int f();", false, true, Settings::Unspecified, "test.cpp", true));
tokenizeAndStringify("[[deprecated]] int f();", false, true, Settings::Native, "test.cpp", true));
ASSERT_EQUALS("[ [ deprecated ] ] int f ( ) ;",
tokenizeAndStringify("[[deprecated]] int f();", false, true, Settings::Unspecified, "test.cpp", false));
tokenizeAndStringify("[[deprecated]] int f();", false, true, Settings::Native, "test.cpp", false));
ASSERT_EQUALS("[ [ deprecated ] ] int f ( ) ;",
tokenizeAndStringify("[[deprecated]] int f();", false, true, Settings::Unspecified, "test.c", true));
tokenizeAndStringify("[[deprecated]] int f();", false, true, Settings::Native, "test.c", true));
}
void simplifyCaseRange() {
@ -8340,7 +8340,7 @@ private:
ASSERT_EQUALS("class Fred { } ;", tokenizeAndStringify("class DLLEXPORT Fred { } ;"));
ASSERT_EQUALS("class Fred : Base { } ;", tokenizeAndStringify("class Fred FINAL : Base { } ;"));
// Regression for C code:
ASSERT_EQUALS("struct Fred { } ;", tokenizeAndStringify("struct DLLEXPORT Fred { } ;", false, true, Settings::Unspecified, "test.c"));
ASSERT_EQUALS("struct Fred { } ;", tokenizeAndStringify("struct DLLEXPORT Fred { } ;", false, true, Settings::Native, "test.c"));
}
void sizeofAddParentheses() {

View File

@ -60,7 +60,7 @@ private:
TEST_CASE(ignore_declaration); // ignore declaration
}
void check(const char code[], Settings::PlatformType platform = Settings::Unspecified) {
void check(const char code[], Settings::PlatformType platform = Settings::Native) {
// Clear the error buffer..
errout.str("");

View File

@ -79,7 +79,7 @@ private:
}
void check(const char code[], Settings::PlatformType platform = Settings::Unspecified) {
void check(const char code[], Settings::PlatformType platform = Settings::Native) {
// Clear the error buffer..
errout.str("");