Fixed #6215 (Move Windows platform types into library)

This commit is contained in:
Robert Reif 2014-10-19 07:34:40 +02:00 committed by Daniel Marjamäki
parent 0ed2b580b2
commit e2f72b4cb1
12 changed files with 1180 additions and 249 deletions

View File

@ -1,5 +1,890 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<def format="1"> <def format="1">
<platformtype name="ACCESS_MASK" value="long">
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
<unsigned/>
</platformtype>
<platformtype name="ATOM" value="short">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="BOOL" value="int">
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="BOOLEAN" value="char">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="BYTE" value="char">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="CCHAR" value="char">
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="CHAR" value="char">
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="COLORREF" value="long">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="DWORD" value="long">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="DWORD32" value="int">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="DWORD64" value="long">
<unsigned/>
<long/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="DWORD_PTR" value="long">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
</platformtype>
<platformtype name="DWORD_PTR" value="long">
<unsigned/>
<long/>
<platform type="win64"/>
</platformtype>
<platformtype name="FLOAT" value="float">
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HACCEL" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HANDLE" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HAGENT" value="long">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HAGENTSESSION" value="long">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HBITMAP" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HBRUSH" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HCOLORSPACE" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HCURSOR" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HCONV" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HCONVLIST" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HDC" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HDDEDATA" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HDESK" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HDROP" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HDWP" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HENHMETAFILE" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HFILE" value="int">
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HFONT" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HGDIOBJ" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HGLOBAL" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HHOOK" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HICON" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HINSTANCE" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HKEY" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HKL" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HLOCAL" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HMENU" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HMETAFILE" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HMODULE" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HMONITOR" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HPALETTE" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HPEN" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HRESULT" value="long">
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HRGN" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HRSRC" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HWND" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HSZ" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HWINSTA" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HALF_PTR" value="short">
<platform type="win32A"/>
<platform type="win32W"/>
</platformtype>
<platformtype name="HALF_PTR" value="int">
<platform type="win64"/>
</platformtype>
<platformtype name="HCALL" value="long">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HLINE" value="long">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HLINEAPP" value="long">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HPHONE" value="long">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="HPHONEAPP" value="long">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="INT" value="int">
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="INT8" value="char">
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="INT16" value="short">
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="INT32" value="int">
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="INT64" value="long">
<long/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="INT_PTR" value="int">
<platform type="win32A"/>
<platform type="win32W"/>
</platformtype>
<platformtype name="INT_PTR" value="long">
<long/>
<platform type="win64"/>
</platformtype>
<platformtype name="LANGID" value="short">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LCID" value="long">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LCTYPE" value="long">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LGRPID" value="long">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LONG" value="long">
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LONG32" value="int">
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LONG64" value="long">
<long/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LONGLONG" value="long">
<long/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LONG_PTR" value="long">
<platform type="win32A"/>
<platform type="win32W"/>
</platformtype>
<platformtype name="LONG_PTR" value="long">
<long/>
<platform type="win64"/>
</platformtype>
<platformtype name="LPBOOL" value="int">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LPARAM" value="long">
<platform type="win32A"/>
<platform type="win32W"/>
</platformtype>
<platformtype name="LPARAM" value="long">
<long/>
<platform type="win64"/>
</platformtype>
<platformtype name="LPBYTE" value="char">
<unsigned/>
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LPCOLORREF" value="long">
<unsigned/>
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LPCSTR" value="char">
<const_ptr/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LPCTSTR" value="char">
<const_ptr/>
<platform type="win32A"/>
</platformtype>
<platformtype name="LPCTSTR" value="wchar_t">
<const_ptr/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LPCVOID" value="void">
<const_ptr/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LPCWSTR" value="wchar_t">
<const_ptr/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LPDWORD" value="long">
<unsigned/>
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LPINT" value="int">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LPLONG" value="long">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LPSTR" value="char">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LPTSTR" value="char">
<pointer/>
<platform type="win32A"/>
</platformtype>
<platformtype name="LPTSTR" value="wchar_t">
<pointer/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LPVOID" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LPWORD" value="short">
<unsigned/>
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LPWSTR" value="wchar_t">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="LRESULT" value="long">
<platform type="win32A"/>
<platform type="win32W"/>
</platformtype>
<platformtype name="LRESULT" value="long">
<long/>
<platform type="win64"/>
</platformtype>
<platformtype name="MMRESULT" value="int">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="NTSTATUS" value="long">
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PBOOL" value="int">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PBOOLEAN" value="char">
<unsigned/>
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PBYTE" value="char">
<unsigned/>
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PCHAR" value="char">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PCSTR" value="char">
<const_ptr/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PCTSTR" value="char">
<const_ptr/>
<platform type="win32A"/>
</platformtype>
<platformtype name="PCTSTR" value="wchar_t">
<const_ptr/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PDWORD" value="long">
<unsigned/>
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PHANDLE" value="void">
<ptr_ptr/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PINT" value="int">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PLONG" value="long">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PSTR" value="char">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PTSTR" value="char">
<pointer/>
<platform type="win32A"/>
</platformtype>
<platformtype name="PTSTR" value="wchar_t">
<pointer/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PUCHAR" value="char">
<unsigned/>
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PULONG" value="long">
<unsigned/>
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PUSHORT" value="short">
<unsigned/>
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PVOID" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PWCHAR" value="wchar_t">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PWORD" value="short">
<unsigned/>
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="PWSTR" value="wchar_t">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="QWORD" value="long">
<unsigned/>
<long/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="SC_LOCK" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="SC_HANDLE" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="SERVICE_STATUS_HANDLE" value="void">
<pointer/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="SHORT" value="short">
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="SIZE_T" value="long">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
</platformtype>
<platformtype name="SIZE_T" value="long">
<unsigned/>
<long/>
<platform type="win64"/>
</platformtype>
<platformtype name="SOCKET" value="int">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="SSIZE_T" value="long">
<platform type="win32A"/>
<platform type="win32W"/>
</platformtype>
<platformtype name="SSIZE_T" value="long">
<long/>
<platform type="win64"/>
</platformtype>
<platformtype name="TBYTE" value="char">
<unsigned/>
<platform type="win32A"/>
</platformtype>
<platformtype name="TBYTE" value="wchar_t">
<unsigned/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="TCHAR" value="char">
<platform type="win32A"/>
</platformtype>
<platformtype name="TCHAR" value="wchar_t">
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="UCHAR" value="char">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="UHALF_PTR" value="short">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
</platformtype>
<platformtype name="UHALF_PTR" value="int">
<unsigned/>
<platform type="win64"/>
</platformtype>
<platformtype name="UINT" value="int">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="UINT8" value="char">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="UINT16" value="short">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="UINT32" value="int">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="UINT64" value="long">
<unsigned/>
<long/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="UINT_PTR" value="int">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
</platformtype>
<platformtype name="UINT_PTR" value="long">
<unsigned/>
<long/>
<platform type="win64"/>
<platform type="win64"/>
</platformtype>
<platformtype name="ULONG" value="long">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="ULONG32" value="int">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="ULONG64" value="long">
<unsigned/>
<long/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="ULONGLONG" value="long">
<unsigned/>
<long/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="ULONG_PTR" value="long">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
</platformtype>
<platformtype name="ULONG_PTR" value="long">
<unsigned/>
<long/>
<platform type="win64"/>
</platformtype>
<platformtype name="USHORT" value="short">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="USN" value="long">
<long/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="VOID" value="void">
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="WCHAR" value="wchar_t">
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="WORD" value="short">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
<platform type="win64"/>
</platformtype>
<platformtype name="WPARAM" value="int">
<unsigned/>
<platform type="win32A"/>
<platform type="win32W"/>
</platformtype>
<platformtype name="WPARAM" value="long">
<unsigned/>
<long/>
<platform type="win64"/>
</platformtype>
<resource> <resource>
<alloc init="true">CreatePen</alloc> <alloc init="true">CreatePen</alloc>
<alloc init="true">CreateBrushIndirect</alloc> <alloc init="true">CreateBrushIndirect</alloc>
@ -538,71 +1423,8 @@
<not-null/> <not-null/>
</arg> </arg>
</function> </function>
<podtype name="ACCESS_MASK" sign="u" size="4"/>
<podtype name="ATOM" sign="u" size="2"/>
<podtype name="BOOL" sign="s" size="4"/>
<podtype name="BOOLEAN" sign="u" size="1"/>
<podtype name="BYTE" sign="u" size="1"/>
<podtype name="CCHAR" sign="s" size="1"/>
<podtype name="CHAR" sign="s" size="1"/>
<podtype name="COLORREF" sign="u" size="4"/>
<podtype name="DWORD" sign="u" size="4"/>
<podtype name="DWORDLONG" sign="u" size="8"/>
<podtype name="DWORD_PTR" sign="u"/>
<podtype name="DWORD32" sign="u" size="4"/>
<podtype name="DWORD64" sign="u" size="8"/>
<podtype name="HAGENT" sign="u" size="4"/>
<podtype name="HAGENTSESSION" sign="u" size="4"/>
<podtype name="HALF_PTR" sign="s"/>
<podtype name="HCALL" sign="u" size="4"/>
<podtype name="HFILE" sign="s" size="4"/>
<podtype name="HLINE" sign="u" size="4"/>
<podtype name="HLINEAPP" sign="u" size="4"/>
<podtype name="HPHONE" sign="u" size="4"/>
<podtype name="HPHONEAPP" sign="u" size="4"/>
<podtype name="HRESULT" sign="s" size="4"/>
<podtype name="INT" sign="s" size="4"/>
<podtype name="INT_PTR" sign="s"/>
<podtype name="INT8" sign="s" size="1"/>
<podtype name="INT16" sign="s" size="2"/>
<podtype name="INT32" sign="s" size="4"/>
<podtype name="INT64" sign="s" size="8"/>
<podtype name="LANGID" sign="u" size="2"/>
<podtype name="LARGE_INTEGER" sign="s" size="8"/> <podtype name="LARGE_INTEGER" sign="s" size="8"/>
<podtype name="LCID" sign="u" size="4"/>
<podtype name="LCTYPE" sign="u" size="4"/>
<podtype name="LGRPID" sign="u" size="4"/>
<podtype name="LONG" sign="s" size="4"/>
<podtype name="LONGLONG" sign="s" size="8"/>
<podtype name="LONG_PTR" sign="s"/>
<podtype name="LONG32" sign="s" size="4"/>
<podtype name="LONG64" sign="s" size="8"/>
<podtype name="LPARAM" sign="s"/>
<podtype name="LRESULT" sign="s"/>
<podtype name="NET_API_STATUS" sign="u" size="4"/>
<podtype name="NTSTATUS" sign="s" size="4"/>
<podtype name="POINTER_SIGNED" sign="s"/> <podtype name="POINTER_SIGNED" sign="s"/>
<podtype name="POINTER_UNSIGNED" sign="u"/> <podtype name="POINTER_UNSIGNED" sign="u"/>
<podtype name="QWORD" sign="u" size="8"/>
<podtype name="SHORT" sign="s" size="2"/>
<podtype name="SIZE_T" sign="u"/>
<podtype name="SSIZE_T" sign="s"/>
<podtype name="UCHAR" sign="u" size="1"/>
<podtype name="UHALF_PTR" sign="u"/>
<podtype name="UINT" sign="u" size="4"/>
<podtype name="UINT_PTR" sign="u"/>
<podtype name="UINT8" sign="u" size="1"/>
<podtype name="UINT16" sign="u" size="2"/>
<podtype name="UINT32" sign="u" size="4"/>
<podtype name="UINT64" sign="u" size="8"/>
<podtype name="ULARGE_INTEGER" sign="u" size="8"/> <podtype name="ULARGE_INTEGER" sign="u" size="8"/>
<podtype name="ULONG" sign="u" size="4"/>
<podtype name="ULONGLONG" sign="u" size="8"/>
<podtype name="ULONG_PTR" sign="u"/>
<podtype name="ULONG32" sign="u" size="4"/>
<podtype name="ULONG64" sign="u" size="8"/>
<podtype name="USHORT" sign="u" size="2"/>
<podtype name="USN" sign="s" size="8"/>
<podtype name="WORD" sign="u" size="2"/>
<podtype name="WPARAM" sign="u"/>
</def> </def>

View File

@ -534,6 +534,12 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
case Library::UNSUPPORTED_FORMAT: case Library::UNSUPPORTED_FORMAT:
errmsg = "File is of unsupported format version"; errmsg = "File is of unsupported format version";
break; break;
case Library::DUPLICATE_PLATFORM_TYPE:
errmsg = "Duplicate platform type";
break;
case Library::PLATFORM_TYPE_REDEFINED:
errmsg = "Platform type redefined";
break;
} }
if (!err.reason.empty()) if (!err.reason.empty())
errmsg += " '" + err.reason + "'"; errmsg += " '" + err.reason + "'";

View File

@ -699,10 +699,13 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
bool posix = true; bool posix = true;
if (settings.standards.posix) if (settings.standards.posix)
posix = (settings.library.load(argv[0], "posix.cfg").errorcode == Library::OK); posix = (settings.library.load(argv[0], "posix.cfg").errorcode == Library::OK);
bool windows = true;
if (settings.isWindowsPlatform())
windows = (settings.library.load(argv[0], "windows.cfg").errorcode == Library::OK);
if (!std || !posix) { if (!std || !posix || !windows) {
const std::list<ErrorLogger::ErrorMessage::FileLocation> callstack; const std::list<ErrorLogger::ErrorMessage::FileLocation> callstack;
const std::string msg("Failed to load " + std::string(!std ? "std.cfg" : "posix.cfg") + ". Your Cppcheck installation is broken, please re-install."); const std::string msg("Failed to load " + std::string(!std ? "std.cfg" : !posix ? "posix.cfg" : "windows.cfg") + ". Your Cppcheck installation is broken, please re-install.");
#ifdef CFGDIR #ifdef CFGDIR
const std::string details("The Cppcheck binary was compiled with CFGDIR set to \"" + const std::string details("The Cppcheck binary was compiled with CFGDIR set to \"" +
std::string(CFGDIR) + "\" and will therefore search for " std::string(CFGDIR) + "\" and will therefore search for "

View File

@ -646,9 +646,12 @@ Settings MainWindow::GetCppcheckSettings()
bool posix = true; bool posix = true;
if (result.standards.posix) if (result.standards.posix)
posix = (LoadLibrary(&result.library, "posix.cfg").errorcode == Library::ErrorCode::OK); posix = (LoadLibrary(&result.library, "posix.cfg").errorcode == Library::ErrorCode::OK);
bool windows = true;
if (result.platformType == Settings::Win32A || result.platformType == Settings::Win32W || result.platformType == Settings::Win64)
windows = (LoadLibrary(&result.library, "windows.cfg").errorcode == Library::ErrorCode::OK);
if (!std || !posix) if (!std || !posix || !windows)
QMessageBox::warning(this, tr("Error"), tr("Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located.").arg(!std ? "std.cfg" : "posix.cfg")); QMessageBox::critical(this, tr("Error"), tr("Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located.").arg(!std ? "std.cfg" : !posix ? "posix.cfg" : "windows.cfg"));
if (result._jobs <= 1) { if (result._jobs <= 1) {
result._jobs = 1; result._jobs = 1;

View File

@ -46,6 +46,7 @@ Library::Error Library::load(const char exename[], const char path[])
return Error(); return Error();
} }
std::string absolute_path;
// open file.. // open file..
tinyxml2::XMLDocument doc; tinyxml2::XMLDocument doc;
tinyxml2::XMLError error = doc.LoadFile(path); tinyxml2::XMLError error = doc.LoadFile(path);
@ -55,6 +56,8 @@ Library::Error Library::load(const char exename[], const char path[])
if (Path::getFilenameExtension(fullfilename) == "") { if (Path::getFilenameExtension(fullfilename) == "") {
fullfilename += ".cfg"; fullfilename += ".cfg";
error = doc.LoadFile(fullfilename.c_str()); error = doc.LoadFile(fullfilename.c_str());
if (error != tinyxml2::XML_ERROR_FILE_NOT_FOUND)
absolute_path = Path::getAbsoluteFilePath(fullfilename.c_str());
} }
if (error == tinyxml2::XML_ERROR_FILE_NOT_FOUND) { if (error == tinyxml2::XML_ERROR_FILE_NOT_FOUND) {
@ -69,12 +72,24 @@ Library::Error Library::load(const char exename[], const char path[])
const char *sep = (!cfgfolder.empty() && cfgfolder[cfgfolder.size()-1U]=='/' ? "" : "/"); const char *sep = (!cfgfolder.empty() && cfgfolder[cfgfolder.size()-1U]=='/' ? "" : "/");
const std::string filename(cfgfolder + sep + fullfilename); const std::string filename(cfgfolder + sep + fullfilename);
error = doc.LoadFile(filename.c_str()); error = doc.LoadFile(filename.c_str());
if (error != tinyxml2::XML_ERROR_FILE_NOT_FOUND)
absolute_path = Path::getAbsoluteFilePath(filename.c_str());
} }
} else
absolute_path = Path::getAbsoluteFilePath(path);
if (error == tinyxml2::XML_NO_ERROR) {
if (_files.find(absolute_path) == _files.end()) {
Error err = load(doc);
if (err.errorcode == OK)
_files.insert(absolute_path);
return err;
}
return Error(OK); // ignore duplicates
} }
return (error == tinyxml2::XML_NO_ERROR) ? return Error(error == tinyxml2::XML_ERROR_FILE_NOT_FOUND ? FILE_NOT_FOUND : BAD_XML);
load(doc) :
Error(error == tinyxml2::XML_ERROR_FILE_NOT_FOUND ? FILE_NOT_FOUND : BAD_XML);
} }
bool Library::loadxmldata(const char xmldata[], std::size_t len) bool Library::loadxmldata(const char xmldata[], std::size_t len)
@ -383,6 +398,59 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
podtypes[name] = podType; podtypes[name] = podType;
} }
else if (nodename == "platformtype") {
const char * const type_name = node->Attribute("name");
if (type_name == nullptr)
return Error(MISSING_ATTRIBUTE, "name");
const char *value = node->Attribute("value");
if (value == nullptr)
return Error(MISSING_ATTRIBUTE, "value");
PlatformType type;
type._type = value;
std::set<std::string> platform;
for (const tinyxml2::XMLElement *typenode = node->FirstChildElement(); typenode; typenode = typenode->NextSiblingElement()) {
if (strcmp(typenode->Name(), "platform") == 0) {
const char * const type_attribute = typenode->Attribute("type");
if (type_attribute == nullptr)
return Error(MISSING_ATTRIBUTE, "type");
platform.insert(type_attribute);
} else if (strcmp(typenode->Name(), "signed") == 0)
type._signed = true;
else if (strcmp(typenode->Name(), "unsigned") == 0)
type._unsigned = true;
else if (strcmp(typenode->Name(), "long") == 0)
type._long = true;
else if (strcmp(typenode->Name(), "pointer") == 0)
type._pointer= true;
else if (strcmp(typenode->Name(), "ptr_ptr") == 0)
type._ptr_ptr = true;
else if (strcmp(typenode->Name(), "const_ptr") == 0)
type._const_ptr = true;
else
return Error(BAD_ELEMENT, typenode->Name());
}
if (platform.empty()) {
const PlatformType * const type_ptr = platform_type(type_name, "");
if (type_ptr) {
if (*type_ptr == type)
return Error(DUPLICATE_PLATFORM_TYPE, type_name);
return Error(PLATFORM_TYPE_REDEFINED, type_name);
}
platform_types[type_name] = type;
} else {
std::set<std::string>::const_iterator it;
for (it = platform.begin(); it != platform.end(); ++it) {
const PlatformType * const type_ptr = platform_type(type_name, *it);
if (type_ptr) {
if (*type_ptr == type)
return Error(DUPLICATE_PLATFORM_TYPE, type_name);
return Error(PLATFORM_TYPE_REDEFINED, type_name);
}
platforms[*it]._platform_types[type_name] = type;
}
}
}
else else
return Error(BAD_ELEMENT, node->Name()); return Error(BAD_ELEMENT, node->Name());
} }

View File

@ -46,7 +46,7 @@ class CPPCHECKLIB Library {
public: public:
Library(); Library();
enum ErrorCode { OK, FILE_NOT_FOUND, BAD_XML, BAD_ELEMENT, MISSING_ATTRIBUTE, BAD_ATTRIBUTE, BAD_ATTRIBUTE_VALUE, UNSUPPORTED_FORMAT }; enum ErrorCode { OK, FILE_NOT_FOUND, BAD_XML, BAD_ELEMENT, MISSING_ATTRIBUTE, BAD_ATTRIBUTE, BAD_ATTRIBUTE_VALUE, UNSUPPORTED_FORMAT, DUPLICATE_PLATFORM_TYPE, PLATFORM_TYPE_REDEFINED };
class Error { class Error {
public: public:
@ -330,6 +330,59 @@ public:
return (it != podtypes.end()) ? &(it->second) : nullptr; return (it != podtypes.end()) ? &(it->second) : nullptr;
} }
struct PlatformType {
PlatformType()
: _signed(false)
, _unsigned(false)
, _long(false)
, _pointer(false)
, _ptr_ptr(false)
, _const_ptr(false) {
}
bool operator == (const PlatformType & type) const {
return (_type == type._type &&
_signed == type._signed &&
_unsigned == type._unsigned &&
_long == type._long &&
_pointer == type._pointer &&
_ptr_ptr == type._ptr_ptr &&
_const_ptr == type._const_ptr);
}
bool operator != (const PlatformType & type) const {
return !(*this == type);
}
std::string _type;
bool _signed;
bool _unsigned;
bool _long;
bool _pointer;
bool _ptr_ptr;
bool _const_ptr;
};
struct Platform {
const PlatformType *platform_type(const std::string &name) const {
const std::map<std::string, struct PlatformType>::const_iterator it = _platform_types.find(name);
return (it != _platform_types.end()) ? &(it->second) : nullptr;
}
std::map<std::string, PlatformType> _platform_types;
};
const PlatformType *platform_type(const std::string &name, const std::string & platform) const {
const std::map<std::string, Platform>::const_iterator it = platforms.find(platform);
if (it != platforms.end()) {
const PlatformType * const type = it->second.platform_type(name);
if (type)
return type;
}
const std::map<std::string, PlatformType>::const_iterator it2 = platform_types.find(name);
return (it2 != platform_types.end()) ? &(it2->second) : nullptr;
}
private: private:
class ExportedFunctions { class ExportedFunctions {
public: public:
@ -386,6 +439,7 @@ private:
std::set<std::string> _blocks; std::set<std::string> _blocks;
}; };
int allocid; int allocid;
std::set<std::string> _files;
std::map<std::string, int> _alloc; // allocation functions std::map<std::string, int> _alloc; // allocation functions
std::map<std::string, int> _dealloc; // deallocation functions std::map<std::string, int> _dealloc; // deallocation functions
std::map<std::string, bool> _noreturn; // is function noreturn? std::map<std::string, bool> _noreturn; // is function noreturn?
@ -400,6 +454,8 @@ private:
std::map<std::string,int> _reflection; // invocation of reflection std::map<std::string,int> _reflection; // invocation of reflection
std::map<std::string, std::pair<bool, bool> > _formatstr; // Parameters for format string checking std::map<std::string, std::pair<bool, bool> > _formatstr; // Parameters for format string checking
std::map<std::string, struct PodType> podtypes; // pod types std::map<std::string, struct PodType> podtypes; // pod types
std::map<std::string, PlatformType> platform_types; // platform independent typedefs
std::map<std::string, Platform> platforms; // platform dependent typedefs
const ArgumentChecks * getarg(const std::string &functionName, int argnr) const; const ArgumentChecks * getarg(const std::string &functionName, int argnr) const;

View File

@ -219,3 +219,21 @@ bool Path::isHeader(const std::string &path)
const std::string extension = getFilenameExtensionInLowerCase(path); const std::string extension = getFilenameExtensionInLowerCase(path);
return (extension.compare(0, 2, ".h") == 0); return (extension.compare(0, 2, ".h") == 0);
} }
std::string Path::getAbsoluteFilePath(const std::string& filePath)
{
std::string absolute_path;
#if defined(__linux__) || defined(__sun) || defined(__hpux) || defined(__GNUC__)
char * absolute = realpath(filePath.c_str(), NULL);
if (absolute)
absolute_path = absolute;
free(absolute);
#elif defined(_WIN32)
char absolute[_MAX_PATH];
if (_fullpath(absolute, filePath.c_str(), _MAX_PATH))
absolute_path = absolute;
#else
#error Platform absolute path function needed
#endif
return absolute_path;
}

View File

@ -104,6 +104,13 @@ public:
*/ */
static std::string getRelativePath(const std::string& absolutePath, const std::vector<std::string>& basePaths); static std::string getRelativePath(const std::string& absolutePath, const std::vector<std::string>& basePaths);
/**
* @brief Get an absolute file path from a relative one.
* @param filePath File path to be made absolute.
* @return absolute path, if possible. Otherwise an empty path is returned
*/
static std::string getAbsoluteFilePath(const std::string& filePath);
/** /**
* @brief Check if the file extension indicates that it's a C/C++ source file. * @brief Check if the file extension indicates that it's a C/C++ source file.
* Check if the file has source file extension: *.c;*.cpp;*.cxx;*.c++;*.cc;*.txx * Check if the file has source file extension: *.c;*.cpp;*.cxx;*.c++;*.cc;*.txx

View File

@ -5655,179 +5655,54 @@ void Tokenizer::simplifyPlatformTypes()
} }
} }
if (_settings->platformType == Settings::Win32A || if (_settings->isWindowsPlatform()) {
_settings->platformType == Settings::Win32W || std::string platform_type = _settings->platformType == Settings::Win32A ? "win32A" :
_settings->platformType == Settings::Win64) { _settings->platformType == Settings::Win32W ? "win32W" : "win64";
for (Token *tok = list.front(); tok; tok = tok->next()) { for (Token *tok = list.front(); tok; tok = tok->next()) {
if (tok->type() != Token::eType && tok->type() != Token::eName) if (tok->type() != Token::eType && tok->type() != Token::eName)
continue; continue;
if (!tok->isUpperCaseName()) // All WinAPI types are uppercase. Reduce number of Token::Match calls by this condition. if (!tok->isUpperCaseName()) // All WinAPI types are uppercase. Reduce number of Token::Match calls by this condition.
continue; continue;
if (Token::Match(tok, "BOOL|INT|INT32|HFILE|LONG32")) { const Library::PlatformType * const platformtype = _settings->library.platform_type(tok->str(), platform_type);
tok->originalName(tok->str());
tok->str("int"); if (platformtype) {
} else if (Token::Match(tok, "BOOLEAN|BYTE|UCHAR")) { Token *type_token;
tok->originalName(tok->str()); // check for namespace
tok->str("char"); if (tok->strAt(-1) == "::") {
tok->isUnsigned(true); const Token * tok1 = tok->tokAt(-2);
} else if (tok->str() == "CHAR") { // skip when non-global namespace defined
tok->originalName(tok->str()); if (tok1 && tok1->type() == Token::eName)
tok->str("char"); continue;
} else if (Token::Match(tok, "DWORD|ULONG|COLORREF|LCID|LCTYPE|LGRPID")) { tok = tok->tokAt(-1);
tok->originalName(tok->str()); tok->deleteThis();
tok->str("long");
tok->isUnsigned(true);
} else if (Token::Match(tok, "DWORD_PTR|ULONG_PTR|SIZE_T")) {
tok->originalName(tok->str());
tok->str("long");
tok->isUnsigned(true);
if (_settings->platformType == Settings::Win64)
tok->isLong(true);
} else if (tok->str() == "FLOAT") {
tok->originalName(tok->str());
tok->str("float");
} else if (Token::Match(tok, "HRESULT|LONG")) {
tok->originalName(tok->str());
tok->str("long");
} else if (tok->str() == "INT8") {
tok->originalName(tok->str());
tok->str("char");
tok->isSigned(true);
} else if (Token::Match(tok, "INT64|LONG64|LONGLONG")) {
tok->originalName(tok->str());
tok->str("long");
tok->isLong(true);
} else if (Token::Match(tok, "LONG_PTR|LPARAM|LRESULT|SSIZE_T")) {
tok->originalName(tok->str());
tok->str("long");
if (_settings->platformType == Settings::Win64)
tok->isLong(true);
} else if (Token::Match(tok, "LPBOOL|PBOOL")) {
tok->str("int");
tok->insertToken("*");
} else if (Token::Match(tok, "LPBYTE|PBOOLEAN|PBYTE|PUCHAR")) {
tok->isUnsigned(true);
tok->str("char");
tok->insertToken("*");
} else if (Token::Match(tok, "LPCSTR|PCSTR")) {
tok->str("const");
tok->insertToken("*");
tok->insertToken("char");
} else if (tok->str() == "LPCVOID") {
tok->str("const");
tok->insertToken("*");
tok->insertToken("void");
} else if (Token::Match(tok, "LPDWORD|LPCOLORREF|PDWORD|PULONG")) {
tok->isUnsigned(true);
tok->str("long");
tok->insertToken("*");
} else if (Token::Match(tok, "LPINT|PINT")) {
tok->str("int");
tok->insertToken("*");
} else if (Token::Match(tok, "LPLONG|PLONG")) {
tok->str("long");
tok->insertToken("*");
} else if (Token::Match(tok, "LPSTR|PSTR|PCHAR")) {
tok->str("char");
tok->insertToken("*");
} else if (Token::Match(tok, "PWSTR|PWCHAR")) {
tok->str("wchar_t");
tok->insertToken("*");
} else if (Token::Match(tok, "LPVOID|PVOID|HANDLE|HBITMAP|HBRUSH|HCOLORSPACE|HCURSOR|HDC|HFONT|HGDIOBJ|HGLOBAL|HICON|HINSTANCE|HKEY|HLOCAL|HMENU|HMETAFILE|HMODULE|HPALETTE|HPEN|HRGN|HRSRC|HWND|SERVICE_STATUS_HANDLE|SC_LOCK|SC_HANDLE|HACCEL|HCONV|HCONVLIST|HDDEDATA|HDESK|HDROP|HDWP|HENHMETAFILE|HHOOK|HKL|HMONITOR|HSZ|HWINSTA")) {
tok->str("void");
tok->insertToken("*");
} else if ((tok->str() == "PHANDLE")) {
tok->str("void");
tok->insertToken("*");
tok->insertToken("*");
} else if (Token::Match(tok, "LPWORD|PWORD|PUSHORT")) {
tok->isUnsigned(true);
tok->str("short");
tok->insertToken("*");
} else if (Token::Match(tok, "SHORT|INT16")) {
tok->originalName(tok->str());
tok->str("short");
} else if (Token::Match(tok, "UINT|MMRESULT|SOCKET|ULONG32|UINT32|DWORD32")) {
tok->originalName(tok->str());
tok->isUnsigned(true);
tok->str("int");
} else if (Token::Match(tok, "UINT_PTR|WPARAM")) {
tok->originalName(tok->str());
tok->isUnsigned(true);
if (_settings->platformType == Settings::Win64) {
tok->str("long");
tok->isLong(true);
} else {
tok->str("int");
} }
} else if (Token::Match(tok, "USHORT|WORD|ATOM|LANGID")) { if (platformtype->_const_ptr) {
tok->originalName(tok->str()); tok->str("const");
tok->isUnsigned(true); tok->insertToken("*");
tok->str("short"); tok->insertToken(platformtype->_type);
} else if (tok->str() == "VOID") { type_token = tok;
tok->originalName(tok->str()); } else if (platformtype->_pointer) {
tok->str("void"); tok->str(platformtype->_type);
} else if (tok->str() == "TCHAR") { type_token = tok;
tok->originalName(tok->str()); tok->insertToken("*");
if (_settings->platformType == Settings::Win32A) } else if (platformtype->_ptr_ptr) {
tok->str("char"); tok->str(platformtype->_type);
else { type_token = tok;
tok->str("wchar_t"); tok->insertToken("*");
}
} else if (tok->str() == "TBYTE") {
tok->originalName(tok->str());
tok->isUnsigned(true);
if (_settings->platformType == Settings::Win32A)
tok->str("short");
else
tok->str("char");
} else if (Token::Match(tok, "PTSTR|LPTSTR")) {
if (_settings->platformType == Settings::Win32A) {
tok->str("char");
tok->insertToken("*"); tok->insertToken("*");
} else { } else {
tok->str("wchar_t"); tok->originalName(tok->str());
tok->insertToken("*"); tok->str(platformtype->_type);
type_token = tok;
} }
} else if (Token::Match(tok, "PCTSTR|LPCTSTR")) { if (platformtype->_signed)
tok->str("const"); type_token->isSigned(true);
if (_settings->platformType == Settings::Win32A) { if (platformtype->_unsigned)
tok->insertToken("*"); type_token->isUnsigned(true);
tok->insertToken("char"); if (platformtype->_long)
} else { type_token->isLong(true);
tok->insertToken("*");
tok->insertToken("wchar_t");
}
} else if (Token::Match(tok, "ULONG64|DWORD64|ULONGLONG")) {
tok->originalName(tok->str());
tok->isUnsigned(true);
tok->isLong(true);
tok->str("long");
} else if (tok->str() == "HALF_PTR") {
tok->originalName(tok->str());
if (_settings->platformType == Settings::Win64)
tok->str("int");
else
tok->str("short");
} else if (tok->str() == "INT_PTR") {
tok->originalName(tok->str());
if (_settings->platformType == Settings::Win64) {
tok->str("long");
tok->isLong(true);
} else {
tok->str("int");
}
} else if (tok->str() == "LPWSTR") {
tok->str("wchar_t");
tok->insertToken("*");
} else if (tok->str() == "LPCWSTR") {
tok->str("const");
tok->insertToken("*");
tok->insertToken("wchar_t");
} else if (tok->str() == "WCHAR") {
tok->originalName(tok->str());
tok->str("wchar_t");
} }
} }
} }

View File

@ -33,6 +33,7 @@ private:
void run() { void run() {
LOAD_LIB_2(settings.library, "std.cfg"); LOAD_LIB_2(settings.library, "std.cfg");
LOAD_LIB_2(settings.library, "windows.cfg");
TEST_CASE(coutCerrMisusage); TEST_CASE(coutCerrMisusage);
@ -52,8 +53,6 @@ private:
TEST_CASE(testPrintfArgument); TEST_CASE(testPrintfArgument);
TEST_CASE(testPosixPrintfScanfParameterPosition); // #4900 TEST_CASE(testPosixPrintfScanfParameterPosition); // #4900
LOAD_LIB_2(settings.library, "windows.cfg");
TEST_CASE(testMicrosoftPrintfArgument); // ticket #4902 TEST_CASE(testMicrosoftPrintfArgument); // ticket #4902
TEST_CASE(testMicrosoftScanfArgument); TEST_CASE(testMicrosoftScanfArgument);
TEST_CASE(testMicrosoftCStringFormatArguments); // ticket #4920 TEST_CASE(testMicrosoftCStringFormatArguments); // ticket #4920
@ -3214,6 +3213,18 @@ private:
"}\n", false, false, Settings::Win32A); "}\n", false, false, Settings::Win32A);
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
check("void foo(UINT32 a, ::UINT32 b, Fred::UINT32 c) {\n"
" printf(\"%d %d %d\n\", a, b, c);\n"
"};\n", false, false, Settings::Win32A);
ASSERT_EQUALS("[test.cpp:2]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'UINT32 {aka unsigned int}'.\n"
"[test.cpp:2]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'UINT32 {aka unsigned int}'.\n", errout.str());
check("void foo(LPCVOID a, ::LPCVOID b, Fred::LPCVOID c) {\n"
" printf(\"%d %d %d\n\", a, b, c);\n"
"};\n", false, false, Settings::Win32A);
ASSERT_EQUALS("[test.cpp:2]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'const void *'.\n"
"[test.cpp:2]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'const void *'.\n", errout.str());
} }
void testMicrosoftScanfArgument() { void testMicrosoftScanfArgument() {

View File

@ -34,9 +34,11 @@ public:
private: private:
Settings settings_std; Settings settings_std;
Settings settings_windows;
void run() { void run() {
LOAD_LIB_2(settings_std.library, "std.cfg"); LOAD_LIB_2(settings_std.library, "std.cfg");
LOAD_LIB_2(settings_windows.library, "windows.cfg");
// Make sure the Tokenizer::simplifyTokenList works. // Make sure the Tokenizer::simplifyTokenList works.
// The order of the simplifications is important. So this test // The order of the simplifications is important. So this test
@ -298,6 +300,22 @@ private:
return tokenizer.tokens()->stringifyList(0, !simplify); return tokenizer.tokens()->stringifyList(0, !simplify);
} }
std::string tokWithWindows(const char code[], bool simplify = true, Settings::PlatformType type = Settings::Unspecified) {
errout.str("");
settings_windows.addEnabled("portability");
settings_windows.platform(type);
Tokenizer tokenizer(&settings_windows, this);
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
if (simplify)
tokenizer.simplifyTokenList2();
return tokenizer.tokens()->stringifyList(0, !simplify);
}
std::string tok(const char code[], const char filename[]) { std::string tok(const char code[], const char filename[]) {
errout.str(""); errout.str("");
@ -897,7 +915,7 @@ private:
const char code[] = ";INT32 i[10];\n" const char code[] = ";INT32 i[10];\n"
"sizeof(i[0]);\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::Unspecified));
ASSERT_EQUALS("; int i [ 10 ] ; 4 ;", tok(code, true, Settings::Win32A)); ASSERT_EQUALS("; int i [ 10 ] ; 4 ;", tokWithWindows(code, true, Settings::Win32A));
} }
void sizeof8() { void sizeof8() {

View File

@ -33,8 +33,11 @@ public:
} }
private: private:
Settings settings_windows;
void run() { void run() {
LOAD_LIB_2(settings_windows.library, "windows.cfg");
TEST_CASE(tokenize1); TEST_CASE(tokenize1);
TEST_CASE(tokenize2); TEST_CASE(tokenize2);
TEST_CASE(tokenize3); TEST_CASE(tokenize3);
@ -411,6 +414,7 @@ private:
TEST_CASE(platformUnix64); TEST_CASE(platformUnix64);
TEST_CASE(platformWin32AStringCat); // ticket #5015 TEST_CASE(platformWin32AStringCat); // ticket #5015
TEST_CASE(platformWin32WStringCat); // ticket #5015 TEST_CASE(platformWin32WStringCat); // ticket #5015
TEST_CASE(platformWinWithNamespace);
TEST_CASE(simplifyMathFunctions); // ticket #5031 TEST_CASE(simplifyMathFunctions); // ticket #5031
TEST_CASE(simplifyMathFunctions_sqrt); TEST_CASE(simplifyMathFunctions_sqrt);
@ -499,6 +503,36 @@ private:
return ""; 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) {
errout.str("");
settings_windows.debugwarnings = true;
settings_windows.platform(platform);
settings_windows.standards.cpp = cpp11 ? Standards::CPP11 : Standards::CPP03;
// tokenize..
Tokenizer tokenizer(&settings_windows, this);
std::istringstream istr(code);
tokenizer.tokenize(istr, filename);
if (simplify)
tokenizer.simplifyTokenList2();
// filter out ValueFlow messages..
const std::string debugwarnings = errout.str();
errout.str("");
std::istringstream istr2(debugwarnings.c_str());
std::string line;
while (std::getline(istr2,line)) {
if (line.find("ValueFlow") == std::string::npos)
errout << line << "\n";
}
if (tokenizer.tokens())
return tokenizer.tokens()->stringifyList(false, expand, false, true, false, 0, 0);
else
return "";
}
void tokenize1() { void tokenize1() {
const char code[] = "void f ( )\n" const char code[] = "void f ( )\n"
@ -6323,10 +6357,10 @@ private:
"const wchar_t * lpcwstr ;"; "const wchar_t * lpcwstr ;";
// These types should be defined the same on all Windows platforms // These types should be defined the same on all Windows platforms
std::string win32A = tokenizeAndStringify(code, true, true, Settings::Win32A); std::string win32A = tokenizeAndStringifyWindows(code, true, true, Settings::Win32A);
ASSERT_EQUALS(expected, win32A); ASSERT_EQUALS(expected, win32A);
ASSERT_EQUALS(win32A, tokenizeAndStringify(code, true, true, Settings::Win32W)); ASSERT_EQUALS(win32A, tokenizeAndStringifyWindows(code, true, true, Settings::Win32W));
ASSERT_EQUALS(win32A, tokenizeAndStringify(code, true, true, Settings::Win64)); ASSERT_EQUALS(win32A, tokenizeAndStringifyWindows(code, true, true, Settings::Win64));
} }
void platformWin32() { void platformWin32() {
@ -6397,9 +6431,9 @@ private:
"int int_ptr ;"; "int int_ptr ;";
// These types should be defined the same on all Win32 platforms // These types should be defined the same on all Win32 platforms
std::string win32A = tokenizeAndStringify(code, true, true, Settings::Win32A); std::string win32A = tokenizeAndStringifyWindows(code, true, true, Settings::Win32A);
ASSERT_EQUALS(expected, win32A); ASSERT_EQUALS(expected, win32A);
ASSERT_EQUALS(win32A, tokenizeAndStringify(code, true, true, Settings::Win32W)); ASSERT_EQUALS(win32A, tokenizeAndStringifyWindows(code, true, true, Settings::Win32W));
} }
void platformWin32A() { void platformWin32A() {
@ -6444,8 +6478,8 @@ private:
"scanf ( \"%s\" , dst ) ; " "scanf ( \"%s\" , dst ) ; "
"sscanf ( dst , \"%s\" , dst ) ; " "sscanf ( dst , \"%s\" , dst ) ; "
"} " "} "
"unsigned short tbyte ;"; "unsigned char tbyte ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code, false, true, Settings::Win32A)); ASSERT_EQUALS(expected, tokenizeAndStringifyWindows(code, false, true, Settings::Win32A));
} }
void platformWin32W() { void platformWin32W() {
@ -6476,7 +6510,7 @@ private:
"wchar_t * lptstr ; " "wchar_t * lptstr ; "
"const wchar_t * pctstr ; " "const wchar_t * pctstr ; "
"const wchar_t * lpctstr ; " "const wchar_t * lpctstr ; "
"unsigned char tbyte ; " "unsigned wchar_t tbyte ; "
"void foo ( ) { " "void foo ( ) { "
"wchar_t tc ; tc = L\'c\' ; " "wchar_t tc ; tc = L\'c\' ; "
"wchar_t src [ 10 ] = L\"123456789\" ; " "wchar_t src [ 10 ] = L\"123456789\" ; "
@ -6491,7 +6525,7 @@ private:
"wscanf ( L\"%s\" , dst ) ; " "wscanf ( L\"%s\" , dst ) ; "
"swscanf ( dst , L\"%s\" , dst ) ; " "swscanf ( dst , L\"%s\" , dst ) ; "
"}"; "}";
ASSERT_EQUALS(expected, tokenizeAndStringify(code, false, true, Settings::Win32W)); ASSERT_EQUALS(expected, tokenizeAndStringifyWindows(code, false, true, Settings::Win32W));
} }
void platformWin64() { void platformWin64() {
@ -6561,7 +6595,7 @@ private:
"int half_ptr ; " "int half_ptr ; "
"long long int_ptr ;"; "long long int_ptr ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Settings::Win64)); ASSERT_EQUALS(expected, tokenizeAndStringifyWindows(code, true, true, Settings::Win64));
} }
void platformUnix32() { void platformUnix32() {
@ -6659,13 +6693,23 @@ private:
void platformWin32AStringCat() { //#5150 void platformWin32AStringCat() { //#5150
const char code[] = "TCHAR text[] = _T(\"123\") _T(\"456\") _T(\"789\");"; const char code[] = "TCHAR text[] = _T(\"123\") _T(\"456\") _T(\"789\");";
const char expected[] = "char text [ 10 ] = \"123456789\" ;"; const char expected[] = "char text [ 10 ] = \"123456789\" ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Settings::Win32A)); ASSERT_EQUALS(expected, tokenizeAndStringifyWindows(code, true, true, Settings::Win32A));
} }
void platformWin32WStringCat() { //#5150 void platformWin32WStringCat() { //#5150
const char code[] = "TCHAR text[] = _T(\"123\") _T(\"456\") _T(\"789\");"; const char code[] = "TCHAR text[] = _T(\"123\") _T(\"456\") _T(\"789\");";
const char expected[] = "wchar_t text [ 10 ] = L\"123456789\" ;"; const char expected[] = "wchar_t text [ 10 ] = L\"123456789\" ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Settings::Win32W)); ASSERT_EQUALS(expected, tokenizeAndStringifyWindows(code, true, true, Settings::Win32W));
}
void platformWinWithNamespace() {
const char code1[] = "UINT32 a; ::UINT32 b; foo::UINT32 c;";
const char expected1[] = "unsigned int a ; unsigned int b ; foo :: UINT32 c ;";
ASSERT_EQUALS(expected1, tokenizeAndStringifyWindows(code1, true, true, Settings::Win32A));
const char code2[] = "LPCVOID a; ::LPCVOID b; foo::LPCVOID c;";
const char expected2[] = "const void * a ; const void * b ; foo :: LPCVOID c ;";
ASSERT_EQUALS(expected2, tokenizeAndStringifyWindows(code2, true, true, Settings::Win32A));
} }
void isZeroNumber() const { void isZeroNumber() const {