wxwidgets.cfg: Improved support for wxString to number conversion functions.

This commit is contained in:
orbitcowboy 2018-04-07 20:27:02 +02:00
parent 20f0784c06
commit 270635eb1f
3 changed files with 86 additions and 13 deletions

View File

@ -1378,9 +1378,7 @@
<leak-ignore/>
<returnValue type="int"/>
<use-retval/>
<arg nr="1">
<not-uninit/>
</arg>
<arg nr="1"/>
</function>
<!-- double wxAtof(const wxString & str)-->
<function name="wxAtof">
@ -1388,9 +1386,7 @@
<leak-ignore/>
<returnValue type="double"/>
<use-retval/>
<arg nr="1">
<not-uninit/>
</arg>
<arg nr="1"/>
</function>
<!-- long wxAtol(const wxString & str)-->
<function name="wxAtol">
@ -1398,8 +1394,34 @@
<leak-ignore/>
<returnValue type="long"/>
<use-retval/>
<arg nr="1"/>
</function>
<!-- bool wxString::ToDouble(double * val) const -->
<!-- bool wxString::ToCDouble(double * val) const -->
<function name="wxString::ToDouble,wxString::ToCDouble">
<noreturn>false</noreturn>
<leak-ignore/>
<returnValue type="bool"/>
<arg nr="1">
<not-null/>
</arg>
</function>
<!-- bool wxString::ToLong(long * val, int base = 10) const -->
<!-- bool wxString::ToCLong(long * val, int base = 10) const -->
<!-- bool wxString::ToLongLong(long long * val, int base = 10) const -->
<!-- bool wxString::ToULong(unsigned long * val, int base = 10) const -->
<!-- bool wxString::ToCULong(unsigned long * val, int base = 10) const -->
<!-- bool wxString::ToULongLong(unsigned long long * val, int base = 10) const -->
<function name="wxString::ToLong,wxString::ToCLong,wxString::ToLongLong,wxString::ToULong,wxString::ToCULong,wxString::ToULongLong">
<noreturn>false</noreturn>
<leak-ignore/>
<returnValue type="bool"/>
<arg nr="1">
<not-null/>
</arg>
<arg nr="2" default="10">
<not-uninit/>
<valid>0,2:36</valid>
</arg>
</function>
<define name="DECLARE_EVENT_TABLE()" value="wxDECLARE_EVENT_TABLE()"/>

View File

@ -11,7 +11,7 @@ else # assume we are in repo root
fi
# Cppcheck options
CPPCHECK_OPT='--check-library --enable=information --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr --template="{file}:{line}:{severity}:{id}:{message}"'
CPPCHECK_OPT='--check-library --enable=information --enable=style --error-exitcode=-1 --suppress=missingIncludeSystem --inline-suppr --template="{file}:{line}:{severity}:{id}:{message}"'
# Compiler settings
CXX=g++

View File

@ -44,12 +44,39 @@ void validGuiCode()
}
#endif
void nullPointer(void)
void nullPointer(const wxString &str)
{
// cppcheck-suppress nullPointer
wxLogGeneric(wxLOG_Message, (char*)NULL);
// cppcheck-suppress nullPointer
wxLogMessage((char*)NULL);
double *doublePtr = NULL;
// cppcheck-suppress nullPointer
(void)str.ToDouble(doublePtr);
// cppcheck-suppress nullPointer
(void)str.ToCDouble(doublePtr);
long * longPtr = NULL;
// cppcheck-suppress nullPointer
(void)str.ToLong(longPtr);
// cppcheck-suppress nullPointer
(void)str.ToCLong(longPtr);
unsigned long * ulongPtr = NULL;
// cppcheck-suppress nullPointer
(void)str.ToULong(ulongPtr);
// cppcheck-suppress nullPointer
(void)str.ToCULong(ulongPtr);
long long * longLongPtr = NULL;
// cppcheck-suppress nullPointer
(void)str.ToLongLong(longLongPtr);
unsigned long long * ulongLongPtr = NULL;
// cppcheck-suppress nullPointer
(void)str.ToULongLong(ulongLongPtr);
}
void ignoredReturnValue(const wxString &s)
@ -64,7 +91,7 @@ void ignoredReturnValue(const wxString &s)
wxAtof(s);
}
void invalidFunctionArg(void)
void invalidFunctionArg(const wxString &str)
{
#if wxUSE_SPINCTRL==1
extern wxSpinCtrl spinCtrlInstance;
@ -73,6 +100,14 @@ void invalidFunctionArg(void)
// cppcheck-suppress invalidFunctionArg
spinCtrlInstance.SetBase(5);
#endif
long l;
// cppcheck-suppress invalidFunctionArg
(void)str.ToLong(&l, -1);
// cppcheck-suppress invalidFunctionArg
(void)str.ToLong(&l, 1);
// cppcheck-suppress invalidFunctionArg
(void)str.ToLong(&l, 37);
}
void uninitvar(void)
@ -80,19 +115,35 @@ void uninitvar(void)
wxLogLevel logLevelUninit;
char cBufUninit[10];
char *pcUninit;
wxString emptyString;
// cppcheck-suppress uninitvar
wxLogGeneric(logLevelUninit, "test");
// cppcheck-suppress uninitvar
wxLogMessage(cBufUninit);
// cppcheck-suppress uninitvar
wxLogMessage(pcUninit);
}
void uninitvar_wxString_NumberConversion(const wxString &str, const int numberBase)
{
int uninitInteger;
long l;
long long ll;
unsigned long ul;
unsigned long long ull;
// cppcheck-suppress uninitvar
(void)wxAtoi(emptyString);
(void)str.ToLong(&l, uninitInteger);
// cppcheck-suppress uninitvar
(void)wxAtol(emptyString);
(void)str.ToLongLong(&ll, uninitInteger);
// cppcheck-suppress uninitvar
(void)wxAtof(emptyString);
(void)str.ToULong(&ul, uninitInteger);
// cppcheck-suppress uninitvar
(void)str.ToULongLong(&ull, uninitInteger);
// cppcheck-suppress uninitvar
(void)str.ToCLong(&l, uninitInteger);
// cppcheck-suppress uninitvar
(void)str.ToCULong(&ul, uninitInteger);
}
void uninitvar_SetMenuBar(wxFrame * const framePtr, wxMenuBar * const menuBarPtr)