Added checktype.cpp to VS solution; Fixed MSVC warning about signed/unsigned mismatch
This commit is contained in:
parent
dd5f41f01d
commit
87e6a3501a
|
@ -30,7 +30,7 @@ namespace {
|
||||||
CheckType instance;
|
CheckType instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool astGetSizeSign(const Settings *settings, const Token *tok, int *size, char *sign)
|
static bool astGetSizeSign(const Settings *settings, const Token *tok, unsigned int *size, char *sign)
|
||||||
{
|
{
|
||||||
if (!tok)
|
if (!tok)
|
||||||
return false;
|
return false;
|
||||||
|
@ -43,7 +43,7 @@ static bool astGetSizeSign(const Settings *settings, const Token *tok, int *size
|
||||||
if (tok->str().find("L") != std::string::npos)
|
if (tok->str().find("L") != std::string::npos)
|
||||||
return false;
|
return false;
|
||||||
MathLib::bigint value = MathLib::toLongNumber(tok->str());
|
MathLib::bigint value = MathLib::toLongNumber(tok->str());
|
||||||
int sz;
|
unsigned int sz;
|
||||||
if (value >= -(1<<7) && value <= (1<<7)-1)
|
if (value >= -(1<<7) && value <= (1<<7)-1)
|
||||||
sz = 8;
|
sz = 8;
|
||||||
else if (value >= -(1<<15) && value <= (1<<15)-1)
|
else if (value >= -(1<<15) && value <= (1<<15)-1)
|
||||||
|
@ -66,7 +66,7 @@ static bool astGetSizeSign(const Settings *settings, const Token *tok, int *size
|
||||||
const Variable *var = tok->variable();
|
const Variable *var = tok->variable();
|
||||||
if (!var)
|
if (!var)
|
||||||
return false;
|
return false;
|
||||||
int sz = 0;
|
unsigned int sz = 0;
|
||||||
for (const Token *type = var->typeStartToken(); type; type = type->next()) {
|
for (const Token *type = var->typeStartToken(); type; type = type->next()) {
|
||||||
if (type->str() == "*")
|
if (type->str() == "*")
|
||||||
return false; // <- FIXME: handle pointers
|
return false; // <- FIXME: handle pointers
|
||||||
|
@ -185,7 +185,7 @@ void CheckType::checkIntegerOverflow()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// get size and sign of result..
|
// get size and sign of result..
|
||||||
int size = 0;
|
unsigned int size = 0;
|
||||||
char sign = 0;
|
char sign = 0;
|
||||||
if (!astGetSizeSign(_settings, tok, &size, &sign))
|
if (!astGetSizeSign(_settings, tok, &size, &sign))
|
||||||
continue;
|
continue;
|
||||||
|
@ -228,7 +228,7 @@ void CheckType::checkSignConversion()
|
||||||
if (!tok->isArithmeticalOp())
|
if (!tok->isArithmeticalOp())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int size = 0;
|
unsigned int size = 0;
|
||||||
char sign = 0;
|
char sign = 0;
|
||||||
if (!astGetSizeSign(_settings, tok, &size, &sign))
|
if (!astGetSizeSign(_settings, tok, &size, &sign))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
<ClCompile Include="checkpostfixoperator.cpp" />
|
<ClCompile Include="checkpostfixoperator.cpp" />
|
||||||
<ClCompile Include="checksizeof.cpp" />
|
<ClCompile Include="checksizeof.cpp" />
|
||||||
<ClCompile Include="checkstl.cpp" />
|
<ClCompile Include="checkstl.cpp" />
|
||||||
|
<ClCompile Include="checktype.cpp" />
|
||||||
<ClCompile Include="checkuninitvar.cpp" />
|
<ClCompile Include="checkuninitvar.cpp" />
|
||||||
<ClCompile Include="checkunusedfunctions.cpp" />
|
<ClCompile Include="checkunusedfunctions.cpp" />
|
||||||
<ClCompile Include="checkunusedvar.cpp" />
|
<ClCompile Include="checkunusedvar.cpp" />
|
||||||
|
@ -103,6 +104,7 @@
|
||||||
<ClInclude Include="checkpostfixoperator.h" />
|
<ClInclude Include="checkpostfixoperator.h" />
|
||||||
<ClInclude Include="checksizeof.h" />
|
<ClInclude Include="checksizeof.h" />
|
||||||
<ClInclude Include="checkstl.h" />
|
<ClInclude Include="checkstl.h" />
|
||||||
|
<ClInclude Include="checktype.h" />
|
||||||
<ClInclude Include="checkuninitvar.h" />
|
<ClInclude Include="checkuninitvar.h" />
|
||||||
<ClInclude Include="checkunusedfunctions.h" />
|
<ClInclude Include="checkunusedfunctions.h" />
|
||||||
<ClInclude Include="checkunusedvar.h" />
|
<ClInclude Include="checkunusedvar.h" />
|
||||||
|
|
|
@ -140,6 +140,9 @@
|
||||||
<ClCompile Include="checkcondition.cpp">
|
<ClCompile Include="checkcondition.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="checktype.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="checkbufferoverrun.h">
|
<ClInclude Include="checkbufferoverrun.h">
|
||||||
|
@ -277,6 +280,9 @@
|
||||||
<ClInclude Include="checkcondition.h">
|
<ClInclude Include="checkcondition.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="checktype.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="version.rc" />
|
<ResourceCompile Include="version.rc" />
|
||||||
|
|
|
@ -80,6 +80,7 @@
|
||||||
<ClCompile Include="testtimer.cpp" />
|
<ClCompile Include="testtimer.cpp" />
|
||||||
<ClCompile Include="testtoken.cpp" />
|
<ClCompile Include="testtoken.cpp" />
|
||||||
<ClCompile Include="testtokenize.cpp" />
|
<ClCompile Include="testtokenize.cpp" />
|
||||||
|
<ClCompile Include="testtype.cpp" />
|
||||||
<ClCompile Include="testuninitvar.cpp" />
|
<ClCompile Include="testuninitvar.cpp" />
|
||||||
<ClCompile Include="testunusedfunctions.cpp" />
|
<ClCompile Include="testunusedfunctions.cpp" />
|
||||||
<ClCompile Include="testunusedprivfunc.cpp" />
|
<ClCompile Include="testunusedprivfunc.cpp" />
|
||||||
|
|
|
@ -190,6 +190,9 @@
|
||||||
<ClCompile Include="testcondition.cpp">
|
<ClCompile Include="testcondition.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="testtype.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="options.h">
|
<ClInclude Include="options.h">
|
||||||
|
|
Loading…
Reference in New Issue