Merge branch 'master' of http://github.com/danmar/cppcheck
This commit is contained in:
commit
1f7ef171ee
241
cppcheck.cbproj
241
cppcheck.cbproj
|
@ -1,241 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{861d1a69-8a53-4340-a876-a39d49c61aa7}</ProjectGuid>
|
||||
<Config Condition="'$(Config)'==''">Debug</Config>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''">
|
||||
<Base>true</Base>
|
||||
<Cfg_1>true</Cfg_1>
|
||||
<CfgParent>Base</CfgParent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_2)'!=''">
|
||||
<Base>true</Base>
|
||||
<Cfg_2>true</Cfg_2>
|
||||
<CfgParent>Base</CfgParent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Base)'!=''">
|
||||
<BCC_OptimizeForSpeed>true</BCC_OptimizeForSpeed>
|
||||
<OutputExt>exe</OutputExt>
|
||||
<DCC_CBuilderOutput>JPHNE</DCC_CBuilderOutput>
|
||||
<Defines>NO_STRICT</Defines>
|
||||
<BCC_wamb>true</BCC_wamb>
|
||||
<BCC_wprc>true</BCC_wprc>
|
||||
<BCC_wexc>true</BCC_wexc>
|
||||
<DynamicRTL>true</DynamicRTL>
|
||||
<BCC_wnod>true</BCC_wnod>
|
||||
<BCC_wuse>true</BCC_wuse>
|
||||
<BCC_wbbf>true</BCC_wbbf>
|
||||
<BCC_wdef>true</BCC_wdef>
|
||||
<BCC_wsig>true</BCC_wsig>
|
||||
<ILINK_SelectedWarnings>false</ILINK_SelectedWarnings>
|
||||
<ILINK_AllWarnings>true</ILINK_AllWarnings>
|
||||
<ILINK_ObjectSearchPath>C:\cppcheck;src;cli;lib;externals\tinyxml</ILINK_ObjectSearchPath>
|
||||
<BCC_wnak>true</BCC_wnak>
|
||||
<ProjectType>CppConsoleApplication</ProjectType>
|
||||
<NoVCL>true</NoVCL>
|
||||
<BCC_winl>true</BCC_winl>
|
||||
<BCC_wstl>true</BCC_wstl>
|
||||
<FinalOutputDir>.\</FinalOutputDir>
|
||||
<BCC_wasm>true</BCC_wasm>
|
||||
<BCC_wcln>true</BCC_wcln>
|
||||
<BCC_wpin>true</BCC_wpin>
|
||||
<DCC_UNSAFE_CAST>true</DCC_UNSAFE_CAST>
|
||||
<PackageImports>vcl.bpi;rtl.bpi;bcbie.bpi;vclx.bpi;vclactnband.bpi;xmlrtl.bpi;bcbsmp.bpi;dbrtl.bpi;vcldb.bpi;vcldbx.bpi;bdertl.bpi;A407_R110.bpi;DreamEdit_C6.bpi</PackageImports>
|
||||
<BCC_wamp>true</BCC_wamp>
|
||||
<BCC_wucp>true</BCC_wucp>
|
||||
<BCC_wimp>true</BCC_wimp>
|
||||
<IncludePath>$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;C:\cppcheck;cli;lib;externals;externals\tinyxml</IncludePath>
|
||||
<BCC_wstu>true</BCC_wstu>
|
||||
<BCC_wstv>true</BCC_wstv>
|
||||
<ILINK_LibraryPath>$(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;C:\cppcheck;src;cli;lib;externals\tinyxml</ILINK_LibraryPath>
|
||||
<DCC_UNSAFE_CODE>true</DCC_UNSAFE_CODE>
|
||||
<DCC_UNSAFE_TYPE>true</DCC_UNSAFE_TYPE>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_1)'!=''">
|
||||
<BCC_OptimizeForSpeed>false</BCC_OptimizeForSpeed>
|
||||
<DCC_Optimize>false</DCC_Optimize>
|
||||
<DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>
|
||||
<Defines>_DEBUG;_HAS_ITERATOR_DEBUGGING=1;$(Defines)</Defines>
|
||||
<BCC_wamb>true</BCC_wamb>
|
||||
<BCC_wprc>true</BCC_wprc>
|
||||
<BCC_wexc>true</BCC_wexc>
|
||||
<ILINK_FullDebugInfo>true</ILINK_FullDebugInfo>
|
||||
<BCC_wnod>true</BCC_wnod>
|
||||
<BCC_wuse>true</BCC_wuse>
|
||||
<BCC_InlineFunctionExpansion>false</BCC_InlineFunctionExpansion>
|
||||
<BCC_wbbf>true</BCC_wbbf>
|
||||
<BCC_wdef>true</BCC_wdef>
|
||||
<BCC_wsig>true</BCC_wsig>
|
||||
<ILINK_DisableIncrementalLinking>true</ILINK_DisableIncrementalLinking>
|
||||
<BCC_UseRegisterVariables>None</BCC_UseRegisterVariables>
|
||||
<DCC_Define>DEBUG</DCC_Define>
|
||||
<BCC_DebugLineNumbers>true</BCC_DebugLineNumbers>
|
||||
<BCC_wnak>true</BCC_wnak>
|
||||
<BCC_winl>true</BCC_winl>
|
||||
<BCC_wstl>true</BCC_wstl>
|
||||
<BCC_SelectedWarnings>true</BCC_SelectedWarnings>
|
||||
<FinalOutputDir>.\</FinalOutputDir>
|
||||
<BCC_wasm>true</BCC_wasm>
|
||||
<BCC_wcln>true</BCC_wcln>
|
||||
<BCC_wpin>true</BCC_wpin>
|
||||
<IntermediateOutputDir>bcb_Debug</IntermediateOutputDir>
|
||||
<BCC_wamp>true</BCC_wamp>
|
||||
<BCC_wucp>true</BCC_wucp>
|
||||
<BCC_wimp>true</BCC_wimp>
|
||||
<BCC_AllWarnings>false</BCC_AllWarnings>
|
||||
<TASM_DisplaySourceLines>true</TASM_DisplaySourceLines>
|
||||
<BCC_wpar>true</BCC_wpar>
|
||||
<BCC_StackFrames>true</BCC_StackFrames>
|
||||
<BCC_wstu>true</BCC_wstu>
|
||||
<BCC_wstv>true</BCC_wstv>
|
||||
<BCC_DisableOptimizations>true</BCC_DisableOptimizations>
|
||||
<ILINK_LibraryPath>$(BDS)\lib\debug;$(ILINK_LibraryPath)</ILINK_LibraryPath>
|
||||
<TASM_Debugging>Full</TASM_Debugging>
|
||||
<BCC_SourceDebuggingOn>true</BCC_SourceDebuggingOn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_2)'!=''">
|
||||
<Defines>NDEBUG;$(Defines)</Defines>
|
||||
<ILINK_SelectedWarnings>false</ILINK_SelectedWarnings>
|
||||
<ILINK_AllWarnings>true</ILINK_AllWarnings>
|
||||
<BCC_winl>false</BCC_winl>
|
||||
<BCC_SelectedWarnings>true</BCC_SelectedWarnings>
|
||||
<IntermediateOutputDir>Release</IntermediateOutputDir>
|
||||
<BCC_AllWarnings>false</BCC_AllWarnings>
|
||||
<BCC_waus>false</BCC_waus>
|
||||
<ILINK_LibraryPath>$(BDS)\lib\release;$(ILINK_LibraryPath)</ILINK_LibraryPath>
|
||||
<TASM_Debugging>None</TASM_Debugging>
|
||||
</PropertyGroup>
|
||||
<ProjectExtensions>
|
||||
<Borland.Personality>CPlusPlusBuilder.Personality</Borland.Personality>
|
||||
<Borland.ProjectType>CppConsoleApplication</Borland.ProjectType>
|
||||
<BorlandProject>
|
||||
<BorlandProject><CPlusPlusBuilder.Personality><VersionInfo><VersionInfo Name="IncludeVerInfo">False</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">1</VersionInfo><VersionInfo Name="MinorVer">0</VersionInfo><VersionInfo Name="Release">0</VersionInfo><VersionInfo Name="Build">0</VersionInfo><VersionInfo Name="Debug">False</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">1053</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName"></VersionInfoKeys><VersionInfoKeys Name="FileDescription"></VersionInfoKeys><VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName"></VersionInfoKeys><VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="Comments"></VersionInfoKeys></VersionInfoKeys><Debugging><Debugging Name="DebugSourceDirs"></Debugging></Debugging><Parameters><Parameters Name="RunParams">applicom.c</Parameters><Parameters Name="Launcher"></Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="DebugCWD">C:\linux-2.6.25.1\drivers\char</Parameters><Parameters Name="HostApplication"></Parameters><Parameters Name="RemoteHost"></Parameters><Parameters Name="RemotePath"></Parameters><Parameters Name="RemoteParams"></Parameters><Parameters Name="RemoteLauncher"></Parameters><Parameters Name="UseRemoteLauncher">False</Parameters><Parameters Name="RemoteCWD"></Parameters><Parameters Name="RemoteDebug">False</Parameters><Parameters Name="Debug Symbols Search Path"></Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters></Parameters><Linker><Linker Name="LibPrefix"></Linker><Linker Name="LibSuffix"></Linker><Linker Name="LibVersion"></Linker></Linker><ProjectProperties><ProjectProperties Name="AutoShowDeps">False</ProjectProperties><ProjectProperties Name="ManagePaths">True</ProjectProperties><ProjectProperties Name="VerifyPackages">True</ProjectProperties></ProjectProperties><HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name="Count">4</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name="Item0">$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;C:\cppcheck;cli;lib;externals</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name="Item1">$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;C:\cppcheck;src;cli;lib</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name="Item2">$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;C:\cppcheck;src</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name="Item3">$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;C:\cppcheck</HistoryLists_hlIncludePath></HistoryLists_hlIncludePath><HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name="Count">1</HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name="Item0">$(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;C:\cppcheck;src;cli;lib;externals\tinyxml</HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name="Item1">$(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;C:\cppcheck;src;cli;lib</HistoryLists_hlILINK_LibraryPath></HistoryLists_hlILINK_LibraryPath><HistoryLists_hlDefines><HistoryLists_hlDefines Name="Count">1</HistoryLists_hlDefines><HistoryLists_hlDefines Name="Item0">NO_STRICT</HistoryLists_hlDefines><HistoryLists_hlDefines Name="Item1">NO_STRICT</HistoryLists_hlDefines></HistoryLists_hlDefines><HistoryLists_hlFinalOutputDir><HistoryLists_hlFinalOutputDir Name="Count">3</HistoryLists_hlFinalOutputDir><HistoryLists_hlFinalOutputDir Name="Item0">.\</HistoryLists_hlFinalOutputDir><HistoryLists_hlFinalOutputDir Name="Item1">bcb_debug</HistoryLists_hlFinalOutputDir><HistoryLists_hlFinalOutputDir Name="Item2">.</HistoryLists_hlFinalOutputDir></HistoryLists_hlFinalOutputDir><HistoryLists_hlBCC_MaxIdentifierLength><HistoryLists_hlBCC_MaxIdentifierLength Name="Count">1</HistoryLists_hlBCC_MaxIdentifierLength><HistoryLists_hlBCC_MaxIdentifierLength Name="Item0">250</HistoryLists_hlBCC_MaxIdentifierLength></HistoryLists_hlBCC_MaxIdentifierLength></CPlusPlusBuilder.Personality></BorlandProject></BorlandProject>
|
||||
</ProjectExtensions>
|
||||
<Import Project="$(MSBuildBinPath)\Borland.Cpp.Targets" />
|
||||
<ItemGroup>
|
||||
<CppCompile Include="cli\cmdlineparser.cpp">
|
||||
<BuildOrder>0</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="cli\cppcheckexecutor.cpp">
|
||||
<BuildOrder>1</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="cli\filelister.cpp">
|
||||
<DependentOn>cli\filelister.h</DependentOn>
|
||||
<BuildOrder>2</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="cli\filelister_unix.cpp">
|
||||
<BuildOrder>3</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="cli\filelister_win32.cpp">
|
||||
<BuildOrder>4</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="cli\main.cpp">
|
||||
<BuildOrder>5</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="cli\pathmatch.cpp">
|
||||
<BuildOrder>6</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="cli\threadexecutor.cpp">
|
||||
<BuildOrder>7</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkautovariables.cpp">
|
||||
<DependentOn>lib\checkautovariables.h</DependentOn>
|
||||
<BuildOrder>8</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkbufferoverrun.cpp">
|
||||
<DependentOn>lib\checkbufferoverrun.h</DependentOn>
|
||||
<BuildOrder>9</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkclass.cpp">
|
||||
<DependentOn>lib\checkclass.h</DependentOn>
|
||||
<BuildOrder>10</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkexceptionsafety.cpp">
|
||||
<DependentOn>lib\checkexceptionsafety.h</DependentOn>
|
||||
<BuildOrder>11</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkmemoryleak.cpp">
|
||||
<DependentOn>lib\checkmemoryleak.h</DependentOn>
|
||||
<BuildOrder>12</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checknullpointer.cpp">
|
||||
<DependentOn>lib\checknullpointer.h</DependentOn>
|
||||
<BuildOrder>13</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkobsoletefunctions.cpp">
|
||||
<DependentOn>lib\checkobsoletefunctions.h</DependentOn>
|
||||
<BuildOrder>14</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkother.cpp">
|
||||
<DependentOn>lib\checkother.h</DependentOn>
|
||||
<BuildOrder>15</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkpostfixoperator.cpp">
|
||||
<DependentOn>lib\checkpostfixoperator.h</DependentOn>
|
||||
<BuildOrder>16</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkstl.cpp">
|
||||
<DependentOn>lib\checkstl.h</DependentOn>
|
||||
<BuildOrder>17</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkuninitvar.cpp">
|
||||
<DependentOn>lib\checkuninitvar.h</DependentOn>
|
||||
<BuildOrder>18</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkunusedfunctions.cpp">
|
||||
<DependentOn>lib\checkunusedfunctions.h</DependentOn>
|
||||
<BuildOrder>19</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\cppcheck.cpp">
|
||||
<BuildOrder>20</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\errorlogger.cpp">
|
||||
<DependentOn>lib\errorlogger.h</DependentOn>
|
||||
<BuildOrder>21</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\executionpath.cpp">
|
||||
<DependentOn>lib\executionpath.h</DependentOn>
|
||||
<BuildOrder>22</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\mathlib.cpp">
|
||||
<DependentOn>lib\mathlib.h</DependentOn>
|
||||
<BuildOrder>23</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\path.cpp">
|
||||
<BuildOrder>24</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\preprocessor.cpp">
|
||||
<DependentOn>lib\preprocessor.h</DependentOn>
|
||||
<BuildOrder>25</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\settings.cpp">
|
||||
<DependentOn>lib\settings.h</DependentOn>
|
||||
<BuildOrder>26</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\symboldatabase.cpp">
|
||||
<DependentOn>lib\symboldatabase.h</DependentOn>
|
||||
<BuildOrder>27</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\timer.cpp">
|
||||
<BuildOrder>28</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\token.cpp">
|
||||
<DependentOn>lib\token.h</DependentOn>
|
||||
<BuildOrder>29</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\tokenize.cpp">
|
||||
<DependentOn>lib\tokenize.h</DependentOn>
|
||||
<BuildOrder>30</BuildOrder>
|
||||
</CppCompile>
|
||||
<BuildConfiguration Include="Debug">
|
||||
<Key>Cfg_1</Key>
|
||||
</BuildConfiguration>
|
||||
<BuildConfiguration Include="Release">
|
||||
<Key>Cfg_2</Key>
|
||||
</BuildConfiguration>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -2,7 +2,7 @@
|
|||
set -e
|
||||
make clean
|
||||
rm -rf coverage_report
|
||||
make test CXXFLAGS="-Wall -Wextra -pedantic -g -fprofile-arcs -ftest-coverage"
|
||||
make test CXXFLAGS="-g -fprofile-arcs -ftest-coverage"
|
||||
gcov lib/*.cpp -o lib/
|
||||
lcov --directory ./ --capture --output-file lcov_tmp.info -b ./
|
||||
lcov --extract lcov_tmp.info "$(pwd)/*" --output-file lcov.info
|
||||
|
|
|
@ -41,7 +41,7 @@ only detects the types of bugs that the compilers normally fail to detect. The
|
|||
goal is no false positives.</p>
|
||||
|
||||
<h2>Download</h2>
|
||||
<p><a class="downloadnow" href="http://downloads.sourceforge.net/cppcheck/cppcheck-1.46.1-x86-Setup.msi"><strong>Download Now!</strong> <em>Version 1.46.1 for Windows</em></a></p>
|
||||
<p><a class="downloadnow" href="http://downloads.sourceforge.net/cppcheck/cppcheck-1.47-x86-Setup.msi"><strong>Download Now!</strong> <em>Version 1.47 for Windows</em></a></p>
|
||||
<p>You can download the standalone tool from our
|
||||
<a href="http://sourceforge.net/projects/cppcheck/">project page</a> or try it
|
||||
as plugin for your favorite IDE:</p>
|
||||
|
|
|
@ -136,12 +136,10 @@ void CheckAutoVariables::autoVariables()
|
|||
{
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *scope = *i;
|
||||
|
||||
// only check functions
|
||||
if (scope->type != Scope::eFunction)
|
||||
continue;
|
||||
|
@ -240,12 +238,10 @@ void CheckAutoVariables::returnPointerToLocalArray()
|
|||
{
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *scope = *i;
|
||||
|
||||
// only check functions
|
||||
if (scope->type != Scope::eFunction)
|
||||
continue;
|
||||
|
@ -325,12 +321,10 @@ void CheckAutoVariables::returnReference()
|
|||
{
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *scope = *i;
|
||||
|
||||
// only check functions
|
||||
if (scope->type != Scope::eFunction)
|
||||
continue;
|
||||
|
@ -407,12 +401,10 @@ void CheckAutoVariables::returncstr()
|
|||
// locate function that returns a const char *..
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *scope = *i;
|
||||
|
||||
// only check functions
|
||||
if (scope->type != Scope::eFunction)
|
||||
continue;
|
||||
|
|
|
@ -1975,6 +1975,9 @@ bool CheckBufferOverrun::ArrayInfo::declare(const Token *tok, const Tokenizer &t
|
|||
_element_size = 0;
|
||||
_varname.clear();
|
||||
|
||||
if (!tok)
|
||||
return false;
|
||||
|
||||
if (!tok->isName() || tok->str() == "return")
|
||||
return false;
|
||||
|
||||
|
@ -2029,6 +2032,9 @@ bool CheckBufferOverrun::ArrayInfo::declare(const Token *tok, const Tokenizer &t
|
|||
atok = atok->tokAt(2);
|
||||
}
|
||||
|
||||
if (Token::Match(atok, "] = !!{"))
|
||||
return false;
|
||||
|
||||
return (!_num.empty() && Token::Match(atok, "] ;|="));
|
||||
}
|
||||
|
||||
|
|
|
@ -68,12 +68,10 @@ void CheckClass::constructors()
|
|||
|
||||
createSymbolDatabase();
|
||||
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *scope = *i;
|
||||
|
||||
// only check classes and structures
|
||||
if (!scope->isClassOrStruct())
|
||||
continue;
|
||||
|
@ -107,7 +105,7 @@ void CheckClass::constructors()
|
|||
clearAllVar(usage);
|
||||
|
||||
std::list<std::string> callstack;
|
||||
initializeVarList(*func, callstack, scope, usage);
|
||||
initializeVarList(*func, callstack, &(*scope), usage);
|
||||
|
||||
// Check if any variables are uninitialized
|
||||
std::list<Variable>::const_iterator var;
|
||||
|
@ -581,12 +579,10 @@ void CheckClass::privateFunctions()
|
|||
|
||||
createSymbolDatabase();
|
||||
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *scope = *i;
|
||||
|
||||
// only check classes and structures
|
||||
if (!scope->isClassOrStruct())
|
||||
continue;
|
||||
|
@ -693,25 +689,15 @@ void CheckClass::unusedPrivateFunctionError(const Token *tok, const std::string
|
|||
// ClassCheck: Check that memset is not used on classes
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckClass::checkMemsetType(const Token *tok, const std::string &type)
|
||||
void CheckClass::checkMemsetType(const Scope *start, const Token *tok, const Token *typeTok)
|
||||
{
|
||||
// check for cached message for this type
|
||||
std::map<std::string, std::string>::const_iterator msg = _memsetClassMessages.find(type);
|
||||
if (msg != _memsetClassMessages.end())
|
||||
{
|
||||
memsetError(tok, type, msg->second);
|
||||
return;
|
||||
}
|
||||
|
||||
// Warn if type is a class or struct that contains any std::* variables
|
||||
const std::string pattern2(std::string("struct|class ") + type + " :|{");
|
||||
const Token *tstruct = Token::findmatch(_tokenizer->tokens(), pattern2.c_str());
|
||||
|
||||
if (!tstruct)
|
||||
const Scope *scope = symbolDatabase->findVariableType(start, typeTok);
|
||||
if (!scope)
|
||||
return;
|
||||
|
||||
// typeKind is either 'struct' or 'class'
|
||||
const std::string &typeKind = tstruct->str();
|
||||
const Token *tstruct = scope->classDef;
|
||||
const std::string &typeName = tstruct->str();
|
||||
|
||||
if (tstruct->tokAt(2)->str() == ":")
|
||||
{
|
||||
|
@ -724,7 +710,7 @@ void CheckClass::checkMemsetType(const Token *tok, const std::string &type)
|
|||
}
|
||||
|
||||
// recursively check all parent classes
|
||||
checkMemsetType(tok, tstruct->str());
|
||||
checkMemsetType(start, tok, tstruct);
|
||||
|
||||
tstruct = tstruct->next();
|
||||
if (tstruct->str() != ",")
|
||||
|
@ -752,7 +738,7 @@ void CheckClass::checkMemsetType(const Token *tok, const std::string &type)
|
|||
tstruct->str().find(":") != std::string::npos)
|
||||
{
|
||||
if (Token::Match(tstruct->next(), "std :: %type% %var% ;"))
|
||||
memsetError(tok, type, tok->str(), "'std::" + tstruct->strAt(3) + "'", typeKind);
|
||||
memsetError(tok, tok->str(), "'std::" + tstruct->strAt(3) + "'", typeName);
|
||||
|
||||
else if (Token::Match(tstruct->next(), "std :: %type% <"))
|
||||
{
|
||||
|
@ -780,12 +766,10 @@ void CheckClass::checkMemsetType(const Token *tok, const std::string &type)
|
|||
|
||||
// found error => report
|
||||
if (Token::Match(tstruct, "> %var% ;"))
|
||||
memsetError(tok, type, tok->str(), "'std::" + typestr + "'", typeKind);
|
||||
memsetError(tok, tok->str(), "'std::" + typestr + "'", typeName);
|
||||
}
|
||||
else if (Token::simpleMatch(tstruct->next(), "virtual"))
|
||||
memsetError(tok, type, tok->str(), "virtual method", typeKind);
|
||||
else if (!Token::Match(tstruct->next(), "static|}"))
|
||||
checkMemsetType(tok, tstruct->next()->str());
|
||||
memsetError(tok, tok->str(), "virtual method", typeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -794,49 +778,60 @@ void CheckClass::noMemset()
|
|||
{
|
||||
createSymbolDatabase();
|
||||
|
||||
// Locate all 'memset' tokens..
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
if (!Token::Match(tok, "memset|memcpy|memmove"))
|
||||
continue;
|
||||
std::list<Function>::const_iterator func;
|
||||
|
||||
std::string type;
|
||||
if (Token::Match(tok, "memset ( %var% , %num% , sizeof ( %type% ) )"))
|
||||
type = tok->strAt(8);
|
||||
else if (Token::Match(tok, "memset ( & %var% , %num% , sizeof ( %type% ) )"))
|
||||
type = tok->strAt(9);
|
||||
else if (Token::Match(tok, "memset ( %var% , %num% , sizeof ( struct %type% ) )"))
|
||||
type = tok->strAt(9);
|
||||
else if (Token::Match(tok, "memset ( & %var% , %num% , sizeof ( struct %type% ) )"))
|
||||
type = tok->strAt(10);
|
||||
else if (Token::Match(tok, "%type% ( %var% , %var% , sizeof ( %type% ) )"))
|
||||
type = tok->strAt(8);
|
||||
else if (Token::Match(tok, "memset ( & %var% , %num% , sizeof ( %var% ) )"))
|
||||
for (func = scope->functionList.begin(); func != scope->functionList.end(); ++func)
|
||||
{
|
||||
unsigned int varid = tok->tokAt(3)->varId();
|
||||
const Variable *var = symbolDatabase->getVariableFromVarId(varid);
|
||||
if (var && var->typeStartToken() == var->typeEndToken())
|
||||
type = var->typeStartToken()->str();
|
||||
// only check functions with bodies
|
||||
if (!func->hasBody)
|
||||
continue;
|
||||
|
||||
// Locate all 'memset' tokens..
|
||||
const Token *end = func->start->link();
|
||||
for (const Token *tok = func->start; tok && tok != end; tok = tok->next())
|
||||
{
|
||||
if (!Token::Match(tok, "memset|memcpy|memmove"))
|
||||
continue;
|
||||
|
||||
const Token *typeTok = 0;
|
||||
if (Token::Match(tok, "memset ( %var% , %num% , sizeof ( %type% ) )"))
|
||||
typeTok = tok->tokAt(8);
|
||||
else if (Token::Match(tok, "memset ( & %var% , %num% , sizeof ( %type% ) )"))
|
||||
typeTok = tok->tokAt(9);
|
||||
else if (Token::Match(tok, "memset ( & %var% , %num% , sizeof ( %type% :: %type% ) )"))
|
||||
typeTok = tok->tokAt(11);
|
||||
else if (Token::Match(tok, "memset ( %var% , %num% , sizeof ( struct %type% ) )"))
|
||||
typeTok = tok->tokAt(9);
|
||||
else if (Token::Match(tok, "memset ( & %var% , %num% , sizeof ( struct %type% ) )"))
|
||||
typeTok = tok->tokAt(10);
|
||||
else if (Token::Match(tok, "%type% ( %var% , %var% , sizeof ( %type% ) )"))
|
||||
typeTok = tok->tokAt(8);
|
||||
else if (Token::Match(tok, "memset ( & %var% , %num% , sizeof ( %var% ) )"))
|
||||
{
|
||||
unsigned int varid = tok->tokAt(3)->varId();
|
||||
const Variable *var = symbolDatabase->getVariableFromVarId(varid);
|
||||
if (var && (var->typeStartToken() == var->typeEndToken() ||
|
||||
Token::Match(var->typeStartToken(), "%type% :: %type%")))
|
||||
typeTok = var->typeEndToken();
|
||||
}
|
||||
|
||||
// No type defined => The tokens didn't match
|
||||
if (!typeTok)
|
||||
continue;
|
||||
|
||||
checkMemsetType(&(*scope), tok, typeTok);
|
||||
}
|
||||
}
|
||||
|
||||
// No type defined => The tokens didn't match
|
||||
if (type.empty())
|
||||
continue;
|
||||
|
||||
checkMemsetType(tok, type);
|
||||
}
|
||||
}
|
||||
|
||||
void CheckClass::memsetError(const Token *tok, const std::string &type, const std::string &message)
|
||||
void CheckClass::memsetError(const Token *tok, const std::string &memfunc, const std::string &classname, const std::string &type)
|
||||
{
|
||||
reportError(tok, Severity::error, "memsetClass", message);
|
||||
// cache the message for this type so we don't have to look it up again
|
||||
_memsetClassMessages[type] = message;
|
||||
}
|
||||
|
||||
void CheckClass::memsetError(const Token *tok, const std::string &type, const std::string &memfunc, const std::string &classname, const std::string &typekind)
|
||||
{
|
||||
memsetError(tok, type, "Using '" + memfunc + "' on " + typekind + " that contains a " + classname);
|
||||
reportError(tok, Severity::error, "memsetClass", "Using '" + memfunc + "' on " + type + " that contains a " + classname);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -850,18 +845,18 @@ void CheckClass::operatorEq()
|
|||
|
||||
createSymbolDatabase();
|
||||
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
std::list<Function>::const_iterator it;
|
||||
std::list<Function>::const_iterator func;
|
||||
|
||||
for (it = (*i)->functionList.begin(); it != (*i)->functionList.end(); ++it)
|
||||
for (func = scope->functionList.begin(); func != scope->functionList.end(); ++func)
|
||||
{
|
||||
if (it->type == Function::eOperatorEqual && it->access != Private)
|
||||
if (func->type == Function::eOperatorEqual && func->access != Private)
|
||||
{
|
||||
if (it->token->strAt(-1) == "void")
|
||||
operatorEqReturnError(it->token->tokAt(-1));
|
||||
if (func->token->strAt(-1) == "void")
|
||||
operatorEqReturnError(func->token->tokAt(-1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -945,12 +940,10 @@ void CheckClass::operatorEqRetRefThis()
|
|||
|
||||
createSymbolDatabase();
|
||||
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *scope = *i;
|
||||
|
||||
// only check classes and structures
|
||||
if (scope->isClassOrStruct())
|
||||
{
|
||||
|
@ -967,7 +960,7 @@ void CheckClass::operatorEqRetRefThis()
|
|||
// find the ')'
|
||||
const Token *tok = func->token->next()->link();
|
||||
|
||||
checkReturnPtrThis(scope, &(*func), tok->tokAt(2), tok->next()->link());
|
||||
checkReturnPtrThis(&(*scope), &(*func), tok->tokAt(2), tok->next()->link());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1001,38 +994,37 @@ void CheckClass::operatorEqToSelf()
|
|||
|
||||
createSymbolDatabase();
|
||||
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *scope = *i;
|
||||
std::list<Function>::const_iterator it;
|
||||
std::list<Function>::const_iterator func;
|
||||
|
||||
// skip classes with multiple inheritance
|
||||
if (scope->derivedFrom.size() > 1)
|
||||
continue;
|
||||
|
||||
for (it = scope->functionList.begin(); it != scope->functionList.end(); ++it)
|
||||
for (func = scope->functionList.begin(); func != scope->functionList.end(); ++func)
|
||||
{
|
||||
if (it->type == Function::eOperatorEqual && it->hasBody)
|
||||
if (func->type == Function::eOperatorEqual && func->hasBody)
|
||||
{
|
||||
// make sure return signature is correct
|
||||
if (Token::Match(it->tokenDef->tokAt(-3), ";|}|{|public:|protected:|private: %type% &") &&
|
||||
it->tokenDef->strAt(-2) == scope->className)
|
||||
if (Token::Match(func->tokenDef->tokAt(-3), ";|}|{|public:|protected:|private: %type% &") &&
|
||||
func->tokenDef->strAt(-2) == scope->className)
|
||||
{
|
||||
// check for proper function parameter signature
|
||||
if ((Token::Match(it->tokenDef->next(), "( const %var% & )") ||
|
||||
Token::Match(it->tokenDef->next(), "( const %var% & %var% )")) &&
|
||||
it->tokenDef->strAt(3) == scope->className)
|
||||
if ((Token::Match(func->tokenDef->next(), "( const %var% & )") ||
|
||||
Token::Match(func->tokenDef->next(), "( const %var% & %var% )")) &&
|
||||
func->tokenDef->strAt(3) == scope->className)
|
||||
{
|
||||
// find the parameter name
|
||||
const Token *rhs = it->token;
|
||||
const Token *rhs = func->token;
|
||||
while (rhs->str() != "&")
|
||||
rhs = rhs->next();
|
||||
rhs = rhs->next();
|
||||
|
||||
// find the ')'
|
||||
const Token *tok = it->token->next()->link();
|
||||
const Token *tok = func->token->next()->link();
|
||||
const Token *tok1 = tok;
|
||||
|
||||
if (tok1 && tok1->tokAt(1) && tok1->tokAt(1)->str() == "{" && tok1->tokAt(1)->link())
|
||||
|
@ -1178,12 +1170,10 @@ void CheckClass::virtualDestructor()
|
|||
|
||||
createSymbolDatabase();
|
||||
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *scope = *i;
|
||||
|
||||
// Skip base classes and namespaces
|
||||
if (scope->derivedFrom.empty())
|
||||
continue;
|
||||
|
@ -1297,12 +1287,10 @@ void CheckClass::checkConst()
|
|||
|
||||
createSymbolDatabase();
|
||||
|
||||
std::list<Scope *>::const_iterator it;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (it = symbolDatabase->scopeList.begin(); it != symbolDatabase->scopeList.end(); ++it)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *scope = *it;
|
||||
|
||||
// only check classes and structures
|
||||
if (!scope->isClassOrStruct())
|
||||
continue;
|
||||
|
@ -1372,12 +1360,12 @@ void CheckClass::checkConst()
|
|||
// check if base class function is virtual
|
||||
if (!scope->derivedFrom.empty())
|
||||
{
|
||||
if (isVirtualFunc(scope, func->tokenDef))
|
||||
if (isVirtualFunc(&(*scope), func->tokenDef))
|
||||
continue;
|
||||
}
|
||||
|
||||
// if nothing non-const was found. write error..
|
||||
if (checkConstFunc(scope, paramEnd))
|
||||
if (checkConstFunc(&(*scope), paramEnd))
|
||||
{
|
||||
std::string classname = scope->className;
|
||||
const Scope *nest = scope->nestedIn;
|
||||
|
|
|
@ -84,6 +84,7 @@ public:
|
|||
* Important: The checking doesn't work on simplified tokens list.
|
||||
*/
|
||||
void noMemset();
|
||||
void checkMemsetType(const Scope *start, const Token *tok, const Token *typeTok);
|
||||
|
||||
/** @brief 'operator=' should return something and it should not be const. */
|
||||
void operatorEq();
|
||||
|
@ -117,8 +118,7 @@ private:
|
|||
void uninitVarError(const Token *tok, const std::string &classname, const std::string &varname);
|
||||
void operatorEqVarError(const Token *tok, const std::string &classname, const std::string &varname);
|
||||
void unusedPrivateFunctionError(const Token *tok, const std::string &classname, const std::string &funcname);
|
||||
void memsetError(const Token *tok, const std::string &type, const std::string &message);
|
||||
void memsetError(const Token *tok, const std::string &type, const std::string &memfunc, const std::string &classname, const std::string &typekind);
|
||||
void memsetError(const Token *tok, const std::string &memfunc, const std::string &classname, const std::string &type);
|
||||
void operatorEqReturnError(const Token *tok);
|
||||
void virtualDestructorError(const Token *tok, const std::string &Base, const std::string &Derived);
|
||||
void thisSubtractionError(const Token *tok);
|
||||
|
@ -134,7 +134,7 @@ private:
|
|||
c.uninitVarError(0, "classname", "varname");
|
||||
c.operatorEqVarError(0, "classname", "");
|
||||
c.unusedPrivateFunctionError(0, "classname", "funcname");
|
||||
c.memsetError(0, "type", "memfunc", "classname", "class");
|
||||
c.memsetError(0, "memfunc", "classname", "class");
|
||||
c.operatorEqReturnError(0);
|
||||
//c.virtualDestructorError(0, "Base", "Derived");
|
||||
c.thisSubtractionError(0);
|
||||
|
@ -228,10 +228,6 @@ private:
|
|||
void initializeVarList(const Function &func, std::list<std::string> &callstack, const Scope *scope, std::vector<Usage> &usage);
|
||||
|
||||
bool canNotCopy(const Scope *scope) const;
|
||||
|
||||
// noMemset helpers
|
||||
void checkMemsetType(const Token *tok, const std::string &type);
|
||||
std::map<std::string, std::string> _memsetClassMessages;
|
||||
};
|
||||
/// @}
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
|
@ -573,12 +573,10 @@ void CheckMemoryLeakInFunction::parse_noreturn()
|
|||
noreturn.insert("errx");
|
||||
noreturn.insert("verrx");
|
||||
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *scope = *i;
|
||||
|
||||
// only check functions
|
||||
if (scope->type != Scope::eFunction)
|
||||
continue;
|
||||
|
@ -2501,12 +2499,10 @@ void CheckMemoryLeakInFunction::checkScope(const Token *Tok1, const std::string
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckMemoryLeakInFunction::checkReallocUsage()
|
||||
{
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *scope = *i;
|
||||
|
||||
// only check functions
|
||||
if (scope->type != Scope::eFunction)
|
||||
continue;
|
||||
|
@ -2654,12 +2650,10 @@ void CheckMemoryLeakInFunction::check()
|
|||
// fill the "noreturn"
|
||||
parse_noreturn();
|
||||
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *scope = *i;
|
||||
|
||||
// only check functions
|
||||
if (scope->type != Scope::eFunction)
|
||||
continue;
|
||||
|
@ -2711,12 +2705,10 @@ void CheckMemoryLeakInClass::check()
|
|||
{
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *scope = *i;
|
||||
|
||||
// only check classes and structures
|
||||
if (scope->isClassOrStruct())
|
||||
{
|
||||
|
@ -2729,9 +2721,9 @@ void CheckMemoryLeakInClass::check()
|
|||
if (var->nameToken()->tokAt(-2)->isStandardType())
|
||||
{
|
||||
if (var->isPrivate())
|
||||
checkPublicFunctions(scope, var->nameToken());
|
||||
checkPublicFunctions(&(*scope), var->nameToken());
|
||||
|
||||
variable(scope, var->nameToken());
|
||||
variable(&(*scope), var->nameToken());
|
||||
}
|
||||
|
||||
// known class?
|
||||
|
@ -2741,9 +2733,9 @@ void CheckMemoryLeakInClass::check()
|
|||
if (var->type()->derivedFrom.empty())
|
||||
{
|
||||
if (var->isPrivate())
|
||||
checkPublicFunctions(scope, var->nameToken());
|
||||
checkPublicFunctions(&(*scope), var->nameToken());
|
||||
|
||||
variable(scope, var->nameToken());
|
||||
variable(&(*scope), var->nameToken());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3177,12 +3169,10 @@ void CheckMemoryLeakNoVar::check()
|
|||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
Scope *scope = *i;
|
||||
|
||||
// only check functions
|
||||
if (scope->type != Scope::eFunction)
|
||||
continue;
|
||||
|
|
|
@ -412,6 +412,22 @@ void CheckNullPointer::nullPointerStructByDeRefAndChec()
|
|||
// name of struct pointer
|
||||
const std::string varname(tok1->str());
|
||||
|
||||
// is pointer local?
|
||||
bool isLocal = false;
|
||||
const Variable * var = _tokenizer->getSymbolDatabase()->getVariableFromVarId(tok1->varId());
|
||||
if (var && (var->isLocal() || var->isArgument()))
|
||||
isLocal = true;
|
||||
|
||||
// member function may or may not nullify the pointer if it's global (#2647)
|
||||
if (!isLocal)
|
||||
{
|
||||
const Token *tok2 = tok1;
|
||||
while (Token::Match(tok2, "%var% ."))
|
||||
tok2 = tok2->tokAt(2);
|
||||
if (Token::Match(tok2,"%var% ("))
|
||||
continue;
|
||||
}
|
||||
|
||||
// count { and } using tok2
|
||||
unsigned int indentlevel2 = 0;
|
||||
for (const Token *tok2 = tok1->tokAt(3); tok2; tok2 = tok2->next())
|
||||
|
@ -448,6 +464,14 @@ void CheckNullPointer::nullPointerStructByDeRefAndChec()
|
|||
else if (indentlevel2 == 0 && tok2->str() == "return")
|
||||
break;
|
||||
|
||||
// Function call: If the pointer is not a local variable it
|
||||
// might be changed by the call.
|
||||
else if (Token::Match(tok2, "[;{}] %var% (") &&
|
||||
Token::simpleMatch(tok2->tokAt(2)->link(), ") ;") && !isLocal)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// Check if pointer is null.
|
||||
// TODO: false negatives for "if (!p || .."
|
||||
else if (Token::Match(tok2, "if ( !| %varid% )|&&", varid1))
|
||||
|
@ -611,7 +635,10 @@ void CheckNullPointer::nullPointerByCheckAndDeRef()
|
|||
null = false;
|
||||
|
||||
// start token = first token after the if/while body
|
||||
tok1 = tok1->previous()->link()->next();
|
||||
tok1 = tok1->previous()->link();
|
||||
tok1 = tok1 ? tok1->next() : NULL;
|
||||
if (!tok1)
|
||||
continue;
|
||||
}
|
||||
|
||||
// Name of the pointer
|
||||
|
|
|
@ -115,7 +115,7 @@ void CheckOther::clarifyCalculation()
|
|||
void CheckOther::clarifyCalculationError(const Token *tok)
|
||||
{
|
||||
reportError(tok,
|
||||
Severity::information,
|
||||
Severity::style,
|
||||
"clarifyCalculation",
|
||||
"Please clarify precedence: 'a*b?..'\n"
|
||||
"Found a suspicious multiplication of condition. Please use parantheses to clarify the code. "
|
||||
|
@ -123,6 +123,44 @@ void CheckOther::clarifyCalculationError(const Token *tok)
|
|||
}
|
||||
|
||||
|
||||
// Clarify condition '(x = a < 0)' into '((x = a) < 0)' or '(x = (a < 0))'
|
||||
void CheckOther::clarifyCondition()
|
||||
{
|
||||
if (!_settings->_checkCodingStyle)
|
||||
return;
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||
{
|
||||
if (Token::Match(tok, "( %var% ="))
|
||||
{
|
||||
for (const Token *tok2 = tok->tokAt(2); tok2; tok2 = tok2->next())
|
||||
{
|
||||
if (tok2->str() == "(" || tok2->str() == "[")
|
||||
tok2 = tok2->link();
|
||||
else if (tok2->str() == "||" ||
|
||||
tok2->str() == "&&" ||
|
||||
tok2->str() == "?" ||
|
||||
tok2->str() == ")")
|
||||
break;
|
||||
else if (Token::Match(tok2, "<|<=|==|!=|>|>= %num% )"))
|
||||
{
|
||||
clarifyConditionError(tok);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CheckOther::clarifyConditionError(const Token *tok)
|
||||
{
|
||||
reportError(tok,
|
||||
Severity::style,
|
||||
"clarifyCondition",
|
||||
"Suspicious condition (assignment+comparison), it can be clarified with parantheses");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CheckOther::warningOldStylePointerCast()
|
||||
{
|
||||
if (!_settings->_checkCodingStyle ||
|
||||
|
@ -235,7 +273,7 @@ void CheckOther::checkSizeofForArrayParameter()
|
|||
void CheckOther::checkRedundantAssignmentInSwitch()
|
||||
{
|
||||
const char switchPattern[] = "switch ( %any% ) { case";
|
||||
const char breakPattern[] = "break|continue|return|exit|goto";
|
||||
const char breakPattern[] = "break|continue|return|exit|goto|throw";
|
||||
const char functionPattern[] = "%var% (";
|
||||
|
||||
// Find the beginning of a switch. E.g.:
|
||||
|
@ -313,7 +351,7 @@ void CheckOther::checkSwitchCaseFallThrough()
|
|||
return;
|
||||
|
||||
const char switchPattern[] = "switch (";
|
||||
const char breakPattern[] = "break|continue|return|exit|goto";
|
||||
const char breakPattern[] = "break|continue|return|exit|goto|throw";
|
||||
|
||||
// Find the beginning of a switch. E.g.:
|
||||
// switch (var) { ...
|
||||
|
@ -1610,25 +1648,23 @@ void CheckOther::functionVariableUsage()
|
|||
// Parse all executing scopes..
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *info = *i;
|
||||
|
||||
// only check functions
|
||||
if (info->type != Scope::eFunction)
|
||||
if (scope->type != Scope::eFunction)
|
||||
continue;
|
||||
|
||||
// First token for the current scope..
|
||||
const Token *const tok1 = info->classStart;
|
||||
const Token *const tok1 = scope->classStart;
|
||||
|
||||
// varId, usage {read, write, modified}
|
||||
Variables variables;
|
||||
|
||||
// scopes
|
||||
ScopeInfo scopes;
|
||||
ScopeInfo *scope = &scopes;
|
||||
ScopeInfo *info = &scopes;
|
||||
|
||||
unsigned int indentlevel = 0;
|
||||
for (const Token *tok = tok1; tok; tok = tok->next())
|
||||
|
@ -1640,14 +1676,14 @@ void CheckOther::functionVariableUsage()
|
|||
scopes = ScopeInfo(tok, NULL);
|
||||
// add the new scope
|
||||
else
|
||||
scope = scope->addChild(tok);
|
||||
info = info->addChild(tok);
|
||||
++indentlevel;
|
||||
}
|
||||
else if (tok->str() == "}")
|
||||
{
|
||||
--indentlevel;
|
||||
|
||||
scope = scope->parent();
|
||||
info = info->parent();
|
||||
|
||||
if (indentlevel == 0)
|
||||
break;
|
||||
|
@ -1678,7 +1714,7 @@ void CheckOther::functionVariableUsage()
|
|||
if (tok->str() == "static")
|
||||
tok = tok->next();
|
||||
|
||||
variables.addVar(tok->next(), Variables::standard, scope,
|
||||
variables.addVar(tok->next(), Variables::standard, info,
|
||||
tok->tokAt(2)->str() == "=" ||
|
||||
tok->previous()->str() == "static");
|
||||
tok = tok->next();
|
||||
|
@ -1694,7 +1730,7 @@ void CheckOther::functionVariableUsage()
|
|||
if (tok->str() == "static")
|
||||
tok = tok->next();
|
||||
|
||||
variables.addVar(tok->next(), Variables::standard, scope, true);
|
||||
variables.addVar(tok->next(), Variables::standard, info, true);
|
||||
|
||||
// check if a local variable is used to initialize this variable
|
||||
if (tok->tokAt(3)->varId() > 0)
|
||||
|
@ -1725,7 +1761,7 @@ void CheckOther::functionVariableUsage()
|
|||
bool isPointer = bool(tok->strAt(1) == "*");
|
||||
const Token * const nametok = tok->tokAt(isPointer ? 2 : 1);
|
||||
|
||||
variables.addVar(nametok, isPointer ? Variables::pointerArray : Variables::array, scope,
|
||||
variables.addVar(nametok, isPointer ? Variables::pointerArray : Variables::array, info,
|
||||
nametok->tokAt(4)->str() == "=" || isStatic);
|
||||
|
||||
// check for reading array size from local variable
|
||||
|
@ -1779,13 +1815,13 @@ void CheckOther::functionVariableUsage()
|
|||
|
||||
bool written = tok->tokAt(3)->str() == "=";
|
||||
|
||||
variables.addVar(tok->tokAt(2), type, scope, written || isStatic);
|
||||
variables.addVar(tok->tokAt(2), type, info, written || isStatic);
|
||||
|
||||
int offset = 0;
|
||||
|
||||
// check for assignment
|
||||
if (written)
|
||||
offset = doAssignment(variables, tok->tokAt(2), false, scope);
|
||||
offset = doAssignment(variables, tok->tokAt(2), false, info);
|
||||
|
||||
tok = tok->tokAt(2 + offset);
|
||||
}
|
||||
|
@ -1812,13 +1848,13 @@ void CheckOther::functionVariableUsage()
|
|||
{
|
||||
bool written = tok->tokAt(4)->str() == "=";
|
||||
|
||||
variables.addVar(tok->tokAt(3), Variables::pointerPointer, scope, written || isStatic);
|
||||
variables.addVar(tok->tokAt(3), Variables::pointerPointer, info, written || isStatic);
|
||||
|
||||
int offset = 0;
|
||||
|
||||
// check for assignment
|
||||
if (written)
|
||||
offset = doAssignment(variables, tok->tokAt(3), false, scope);
|
||||
offset = doAssignment(variables, tok->tokAt(3), false, info);
|
||||
|
||||
tok = tok->tokAt(3 + offset);
|
||||
}
|
||||
|
@ -1849,13 +1885,13 @@ void CheckOther::functionVariableUsage()
|
|||
|
||||
const bool written = tok->strAt(4) == "=";
|
||||
|
||||
variables.addVar(tok->tokAt(3), type, scope, written || isStatic);
|
||||
variables.addVar(tok->tokAt(3), type, info, written || isStatic);
|
||||
|
||||
int offset = 0;
|
||||
|
||||
// check for assignment
|
||||
if (written)
|
||||
offset = doAssignment(variables, tok->tokAt(3), false, scope);
|
||||
offset = doAssignment(variables, tok->tokAt(3), false, info);
|
||||
|
||||
tok = tok->tokAt(3 + offset);
|
||||
}
|
||||
|
@ -1886,7 +1922,7 @@ void CheckOther::functionVariableUsage()
|
|||
if (Token::Match(tok->tokAt(4), "%var%"))
|
||||
varid = tok->tokAt(4)->varId();
|
||||
|
||||
variables.addVar(tok->tokAt(2), type, scope, true);
|
||||
variables.addVar(tok->tokAt(2), type, info, true);
|
||||
|
||||
// check if a local variable is used to initialize this variable
|
||||
if (varid > 0)
|
||||
|
@ -1931,7 +1967,7 @@ void CheckOther::functionVariableUsage()
|
|||
if (tok->str() != "return")
|
||||
{
|
||||
variables.addVar(tok->tokAt(2),
|
||||
tok->next()->str() == "*" ? Variables::pointerArray : Variables::referenceArray, scope,
|
||||
tok->next()->str() == "*" ? Variables::pointerArray : Variables::referenceArray, info,
|
||||
tok->tokAt(6)->str() == "=" || isStatic);
|
||||
|
||||
// check for reading array size from local variable
|
||||
|
@ -1960,7 +1996,7 @@ void CheckOther::functionVariableUsage()
|
|||
tok = tok->next();
|
||||
|
||||
variables.addVar(tok->tokAt(3),
|
||||
tok->tokAt(2)->str() == "*" ? Variables::pointerArray : Variables::referenceArray, scope,
|
||||
tok->tokAt(2)->str() == "*" ? Variables::pointerArray : Variables::referenceArray, info,
|
||||
tok->tokAt(7)->str() == "=" || isStatic);
|
||||
|
||||
// check for reading array size from local variable
|
||||
|
@ -2034,7 +2070,7 @@ void CheckOther::functionVariableUsage()
|
|||
const unsigned int varid1 = tok->varId();
|
||||
const Token *start = tok;
|
||||
|
||||
tok = tok->tokAt(doAssignment(variables, tok, dereference, scope));
|
||||
tok = tok->tokAt(doAssignment(variables, tok, dereference, info));
|
||||
|
||||
if (pre || post)
|
||||
variables.use(varid1);
|
||||
|
@ -2064,7 +2100,7 @@ void CheckOther::functionVariableUsage()
|
|||
if (!start->tokAt(3)->isStandardType())
|
||||
{
|
||||
// lookup the type
|
||||
const Scope *type = symbolDatabase->findVariableType(info, start->tokAt(3));
|
||||
const Scope *type = symbolDatabase->findVariableType(&(*scope), start->tokAt(3));
|
||||
|
||||
// unknown type?
|
||||
if (!type)
|
||||
|
@ -2281,12 +2317,10 @@ void CheckOther::checkVariableScope()
|
|||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *scope = *i;
|
||||
|
||||
// only check functions
|
||||
if (scope->type != Scope::eFunction)
|
||||
continue;
|
||||
|
@ -2910,6 +2944,23 @@ void CheckOther::checkMathFunctions()
|
|||
}
|
||||
}
|
||||
|
||||
/** Is there a function with given name? */
|
||||
static bool isFunction(const std::string &name, const Token *startToken)
|
||||
{
|
||||
const std::string pattern1(name + " (");
|
||||
for (const Token *tok = startToken; tok; tok = tok->next())
|
||||
{
|
||||
// skip executable scopes etc
|
||||
if (tok->str() == "(" || tok->str() == "{")
|
||||
tok = tok->link();
|
||||
|
||||
// function declaration/implementation found
|
||||
if (Token::simpleMatch(tok, pattern1.c_str()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CheckOther::checkMisusedScopedObject()
|
||||
{
|
||||
// Skip this check for .c files
|
||||
|
@ -2922,12 +2973,10 @@ void CheckOther::checkMisusedScopedObject()
|
|||
|
||||
const SymbolDatabase * const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *scope = *i;
|
||||
|
||||
// only check functions
|
||||
if (scope->type != Scope::eFunction)
|
||||
continue;
|
||||
|
@ -2950,7 +2999,7 @@ void CheckOther::checkMisusedScopedObject()
|
|||
if (Token::Match(tok, "[;{}] %var% (")
|
||||
&& Token::simpleMatch(tok->tokAt(2)->link(), ") ;")
|
||||
&& symbolDatabase->isClassOrStruct(tok->next()->str())
|
||||
)
|
||||
&& !isFunction(tok->next()->str(), _tokenizer->tokens()))
|
||||
{
|
||||
tok = tok->next();
|
||||
misusedScopeObjectError(tok, tok->str());
|
||||
|
@ -3044,8 +3093,8 @@ void CheckOther::variableScopeError(const Token *tok, const std::string &varname
|
|||
reportError(tok,
|
||||
Severity::information,
|
||||
"variableScope",
|
||||
"The scope of the variable " + varname + " can be reduced\n"
|
||||
"The scope of the variable " + varname + " can be reduced. Warning: It can be unsafe "
|
||||
"The scope of the variable '" + varname + "' can be reduced\n"
|
||||
"The scope of the variable '" + varname + "' can be reduced. Warning: It can be unsafe "
|
||||
"to fix this message. Be careful. Especially when there are inner loops. Here is an "
|
||||
"example where cppcheck will write that the scope for 'i' can be reduced:\n"
|
||||
"void f(int x)\n"
|
||||
|
|
|
@ -64,6 +64,8 @@ public:
|
|||
checkOther.checkAssignmentInAssert();
|
||||
checkOther.checkSizeofForArrayParameter();
|
||||
checkOther.checkSelfAssignment();
|
||||
|
||||
checkOther.clarifyCondition(); // not simplified because ifAssign
|
||||
}
|
||||
|
||||
/** @brief Run checks against the simplified token list */
|
||||
|
@ -97,6 +99,10 @@ public:
|
|||
void clarifyCalculation();
|
||||
void clarifyCalculationError(const Token *tok);
|
||||
|
||||
/** @brief Suspicious condition (assignment+comparison) */
|
||||
void clarifyCondition();
|
||||
void clarifyConditionError(const Token *tok);
|
||||
|
||||
/** @brief Are there C-style pointer casts in a c++ file? */
|
||||
void warningOldStylePointerCast();
|
||||
|
||||
|
@ -264,6 +270,7 @@ public:
|
|||
c.catchExceptionByValueError(0);
|
||||
c.memsetZeroBytesError(0, "varname");
|
||||
c.clarifyCalculationError(0);
|
||||
c.clarifyConditionError(0);
|
||||
c.incorrectStringCompareError(0, "substr", "\"Hello World\"", "12");
|
||||
c.incrementBooleanError(0);
|
||||
c.comparisonOfBoolWithIntError(0, "varname");
|
||||
|
@ -309,6 +316,7 @@ public:
|
|||
"* Clarify calculation with parantheses\n"
|
||||
"* using increment on boolean\n"
|
||||
"* comparison of a boolean with a non-zero integer\n"
|
||||
"* suspicious condition (assignment+comparison)"
|
||||
|
||||
// optimisations
|
||||
"* optimisation: detect post increment/decrement\n";
|
||||
|
|
|
@ -100,10 +100,11 @@ void CheckStl::iterators()
|
|||
// skip error message if container is a set..
|
||||
if (tok2->varId() > 0)
|
||||
{
|
||||
const Token *decltok = Token::findmatch(_tokenizer->tokens(), "%varid%", tok2->varId());
|
||||
while (decltok && !Token::Match(decltok, "[;{},(]"))
|
||||
decltok = decltok->previous();
|
||||
if (Token::Match(decltok, "%any% const| std :: set"))
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
const Variable *variableInfo = symbolDatabase->getVariableFromVarId(tok2->varId());
|
||||
const Token *decltok = variableInfo ? variableInfo->typeStartToken() : NULL;
|
||||
|
||||
if (Token::Match(decltok, "const| std :: set"))
|
||||
continue; // No warning
|
||||
}
|
||||
|
||||
|
@ -438,8 +439,18 @@ void CheckStl::erase()
|
|||
{
|
||||
if (Token::Match(tok2, "; %var% !="))
|
||||
{
|
||||
const unsigned int varid = tok2->next()->varId();
|
||||
if (varid > 0 && Token::findmatch(_tokenizer->tokens(), "> :: iterator %varid%", varid))
|
||||
// Get declaration token for var..
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
const Variable *variableInfo = symbolDatabase->getVariableFromVarId(tok2->next()->varId());
|
||||
const Token *decltok = variableInfo ? variableInfo->typeEndToken() : NULL;
|
||||
|
||||
// Is variable an iterator?
|
||||
bool isIterator = false;
|
||||
if (decltok && Token::Match(decltok->tokAt(-2), "> :: iterator %varid%", tok2->next()->varId()))
|
||||
isIterator = true;
|
||||
|
||||
// If tok2->next() is an iterator, check scope
|
||||
if (isIterator)
|
||||
EraseCheckLoop::checkScope(this, tok2->next());
|
||||
}
|
||||
break;
|
||||
|
@ -964,6 +975,13 @@ void CheckStl::missingComparison()
|
|||
incrementToken = 0;
|
||||
else if (tok3->str() == "break" || tok3->str() == "return")
|
||||
incrementToken = 0;
|
||||
else if (Token::Match(tok3, "%varid% = %var% . insert ( ++| %varid% ++| ,", iteratorId))
|
||||
{
|
||||
// skip insertion..
|
||||
tok3 = tok3->tokAt(6)->link();
|
||||
if (!tok3)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (incrementToken)
|
||||
missingComparisonError(incrementToken, tok2->tokAt(16));
|
||||
|
|
|
@ -281,15 +281,18 @@ std::string Settings::Suppressions::addSuppression(const std::string &errorId, c
|
|||
{
|
||||
return "Failed to add suppression. No id.";
|
||||
}
|
||||
for (std::string::size_type pos = 0; pos < errorId.length(); ++pos)
|
||||
if (errorId != "*")
|
||||
{
|
||||
if (errorId[pos] < 0 || !std::isalnum(errorId[pos]))
|
||||
for (std::string::size_type pos = 0; pos < errorId.length(); ++pos)
|
||||
{
|
||||
return "Failed to add suppression. Invalid id \"" + errorId + "\"";
|
||||
}
|
||||
if (pos == 0 && std::isdigit(errorId[pos]))
|
||||
{
|
||||
return "Failed to add suppression. Invalid id \"" + errorId + "\"";
|
||||
if (errorId[pos] < 0 || !std::isalnum(errorId[pos]))
|
||||
{
|
||||
return "Failed to add suppression. Invalid id \"" + errorId + "\"";
|
||||
}
|
||||
if (pos == 0 && std::isdigit(errorId[pos]))
|
||||
{
|
||||
return "Failed to add suppression. Invalid id \"" + errorId + "\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -298,6 +301,10 @@ std::string Settings::Suppressions::addSuppression(const std::string &errorId, c
|
|||
|
||||
bool Settings::Suppressions::isSuppressed(const std::string &errorId, const std::string &file, unsigned int line)
|
||||
{
|
||||
if (errorId != "unmatchedSuppression" && _suppressions.find("*") != _suppressions.end())
|
||||
if (_suppressions["*"].isSuppressed(file, line))
|
||||
return true;
|
||||
|
||||
if (_suppressions.find(errorId) == _suppressions.end())
|
||||
return false;
|
||||
|
||||
|
@ -306,6 +313,10 @@ bool Settings::Suppressions::isSuppressed(const std::string &errorId, const std:
|
|||
|
||||
bool Settings::Suppressions::isSuppressedLocal(const std::string &errorId, const std::string &file, unsigned int line)
|
||||
{
|
||||
if (errorId != "unmatchedSuppression" && _suppressions.find("*") != _suppressions.end())
|
||||
if (_suppressions["*"].isSuppressedLocal(file, line))
|
||||
return true;
|
||||
|
||||
if (_suppressions.find(errorId) == _suppressions.end())
|
||||
return false;
|
||||
|
||||
|
|
|
@ -38,30 +38,33 @@
|
|||
SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||
: _tokenizer(tokenizer), _settings(settings), _errorLogger(errorLogger)
|
||||
{
|
||||
// find all namespaces (class,struct and namespace)
|
||||
Scope *scope = new Scope(this, NULL, NULL);
|
||||
scopeList.push_back(scope);
|
||||
// create global scope
|
||||
scopeList.push_back(Scope(this, NULL, NULL));
|
||||
|
||||
// pointer to current scope
|
||||
Scope *scope = &scopeList.back();
|
||||
|
||||
// find all scopes
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||
{
|
||||
// Locate next class
|
||||
if (Token::Match(tok, "class|struct|namespace %var% [{:]"))
|
||||
if (Token::Match(tok, "class|struct|union|namespace %var% [{:]"))
|
||||
{
|
||||
Scope *new_scope = new Scope(this, tok, scope);
|
||||
scopeList.push_back(Scope(this, tok, scope));
|
||||
|
||||
Scope *new_scope = &scopeList.back();
|
||||
const Token *tok2 = tok->tokAt(2);
|
||||
|
||||
// only create base list for classes and structures
|
||||
if (new_scope->isClassOrStruct())
|
||||
{
|
||||
// fill the classAndStructTypes set..
|
||||
classAndStructTypes.insert(new_scope->className);
|
||||
|
||||
// goto initial '{'
|
||||
tok2 = initBaseInfo(new_scope, tok);
|
||||
|
||||
// make sure we have valid code
|
||||
if (!tok2)
|
||||
{
|
||||
delete new_scope;
|
||||
scopeList.pop_back();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -72,14 +75,17 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
// make sure we have valid code
|
||||
if (!new_scope->classEnd)
|
||||
{
|
||||
delete new_scope;
|
||||
scopeList.pop_back();
|
||||
break;
|
||||
}
|
||||
|
||||
scope = new_scope;
|
||||
// fill the classAndStructTypes set..
|
||||
if (new_scope->isClassOrStruct())
|
||||
classAndStructTypes.insert(new_scope->className);
|
||||
|
||||
// add namespace
|
||||
scopeList.push_back(scope);
|
||||
// make the new scope the current scope
|
||||
scope = &scopeList.back();
|
||||
scope->nestedIn->nestedList.push_back(scope);
|
||||
|
||||
tok = tok2;
|
||||
}
|
||||
|
@ -95,6 +101,15 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
continue;
|
||||
}
|
||||
|
||||
// using namespace
|
||||
else if (Token::Match(tok, "using namespace %type% ;|::"))
|
||||
{
|
||||
// save location
|
||||
scope->usingList.push_back(tok);
|
||||
|
||||
tok = tok->tokAt(3);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// check for end of space
|
||||
|
@ -156,16 +171,23 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
// class constructor/destructor
|
||||
else if (function.tokenDef->str() == scope->className)
|
||||
{
|
||||
// destructor
|
||||
if (function.tokenDef->previous()->str() == "~")
|
||||
function.type = Function::eDestructor;
|
||||
|
||||
// copy constructor
|
||||
else if ((Token::Match(function.tokenDef, "%var% ( const %var% & )") ||
|
||||
Token::Match(function.tokenDef, "%var% ( const %var% & %var% )")) &&
|
||||
function.tokenDef->strAt(3) == scope->className)
|
||||
function.type = Function::eCopyConstructor;
|
||||
|
||||
// copy constructor with non-const argument
|
||||
else if ((Token::Match(function.tokenDef, "%var% ( %var% & )") ||
|
||||
Token::Match(function.tokenDef, "%var% ( %var% & %var% )")) &&
|
||||
function.tokenDef->strAt(2) == scope->className)
|
||||
function.type = Function::eCopyConstructor;
|
||||
|
||||
// regular constructor
|
||||
else
|
||||
function.type = Function::eConstructor;
|
||||
|
||||
|
@ -262,7 +284,10 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
|
||||
addNewFunction(&scope, &tok2);
|
||||
if (scope)
|
||||
{
|
||||
scope->functionOf = functionOf;
|
||||
scope->function = &functionOf->functionList.back();
|
||||
}
|
||||
|
||||
tok = tok2;
|
||||
}
|
||||
|
@ -336,6 +361,14 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
function.arg = function.argDef;
|
||||
function.type = Function::eFunction;
|
||||
|
||||
// find start of function '{'
|
||||
const Token *start = tok;
|
||||
while (start && start->str() != "{")
|
||||
start = start->next();
|
||||
|
||||
// save start of function
|
||||
function.start = start;
|
||||
|
||||
addNewFunction(&scope, &tok);
|
||||
|
||||
if (scope)
|
||||
|
@ -382,6 +415,14 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
function.type = Function::eFunction;
|
||||
function.retFuncPtr = true;
|
||||
|
||||
// find start of function '{'
|
||||
const Token *start = tok;
|
||||
while (start && start->str() != "{")
|
||||
start = start->next();
|
||||
|
||||
// save start of function
|
||||
function.start = start;
|
||||
|
||||
addNewFunction(&scope, &tok1);
|
||||
|
||||
if (scope)
|
||||
|
@ -397,6 +438,23 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
|
||||
tok = tok1;
|
||||
}
|
||||
|
||||
// function prototype
|
||||
else if (Token::simpleMatch(argStart->link(), ") ;"))
|
||||
{
|
||||
/** @todo save function prototypes in database someday */
|
||||
tok = argStart->link()->next();
|
||||
continue;
|
||||
}
|
||||
|
||||
// function returning function pointer prototype
|
||||
else if (Token::simpleMatch(argStart->link(), ") ) (") &&
|
||||
Token::simpleMatch(argStart->link()->tokAt(2)->link(), ") ;"))
|
||||
{
|
||||
/** @todo save function prototypes in database someday */
|
||||
tok = argStart->link()->tokAt(2)->link()->next();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (scope->type == Scope::eFunction || scope->isLocal())
|
||||
|
@ -404,60 +462,75 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
if (Token::simpleMatch(tok, "if (") &&
|
||||
Token::simpleMatch(tok->next()->link(), ") {"))
|
||||
{
|
||||
scope = new Scope(this, tok, scope, Scope::eIf, tok->next()->link()->next());
|
||||
tok = tok->next()->link()->next();
|
||||
scopeList.push_back(scope);
|
||||
const Token *tok1 = tok->next()->link()->next();
|
||||
scopeList.push_back(Scope(this, tok, scope, Scope::eIf, tok1));
|
||||
tok = tok1;
|
||||
scope = &scopeList.back();
|
||||
scope->nestedIn->nestedList.push_back(scope);
|
||||
}
|
||||
else if (Token::simpleMatch(tok, "else {"))
|
||||
{
|
||||
scope = new Scope(this, tok, scope, Scope::eElse, tok->next());
|
||||
tok = tok->next();
|
||||
scopeList.push_back(scope);
|
||||
const Token *tok1 = tok->next();
|
||||
scopeList.push_back(Scope(this, tok, scope, Scope::eElse, tok1));
|
||||
tok = tok1;
|
||||
scope = &scopeList.back();
|
||||
scope->nestedIn->nestedList.push_back(scope);
|
||||
}
|
||||
else if (Token::simpleMatch(tok, "else if (") &&
|
||||
Token::simpleMatch(tok->next()->next()->link(), ") {"))
|
||||
{
|
||||
scope = new Scope(this, tok, scope, Scope::eElseIf, tok->next()->next()->link()->next());
|
||||
tok = tok->next()->next()->link()->next();
|
||||
scopeList.push_back(scope);
|
||||
const Token *tok1 = tok->next()->next()->link()->next();
|
||||
scopeList.push_back(Scope(this, tok, scope, Scope::eElseIf, tok1));
|
||||
tok = tok1;
|
||||
scope = &scopeList.back();
|
||||
scope->nestedIn->nestedList.push_back(scope);
|
||||
}
|
||||
else if (Token::simpleMatch(tok, "for (") &&
|
||||
Token::simpleMatch(tok->next()->link(), ") {"))
|
||||
{
|
||||
// save location of initialization
|
||||
const Token *tok1 = tok->tokAt(2);
|
||||
scope = new Scope(this, tok, scope, Scope::eFor, tok->next()->link()->next());
|
||||
tok = tok->next()->link()->next();
|
||||
scopeList.push_back(scope);
|
||||
const Token *tok1 = tok->next()->link()->next();
|
||||
const Token *tok2 = tok->tokAt(2);
|
||||
scopeList.push_back(Scope(this, tok, scope, Scope::eFor, tok1));
|
||||
tok = tok1;
|
||||
scope = &scopeList.back();
|
||||
scope->nestedIn->nestedList.push_back(scope);
|
||||
// check for variable declaration and add it to new scope if found
|
||||
scope->checkVariable(tok1, Local);
|
||||
scope->checkVariable(tok2, Local);
|
||||
}
|
||||
else if (Token::simpleMatch(tok, "while (") &&
|
||||
Token::simpleMatch(tok->next()->link(), ") {"))
|
||||
{
|
||||
scope = new Scope(this, tok, scope, Scope::eWhile, tok->next()->link()->next());
|
||||
tok = tok->next()->link()->next();
|
||||
scopeList.push_back(scope);
|
||||
const Token *tok1 = tok->next()->link()->next();
|
||||
scopeList.push_back(Scope(this, tok, scope, Scope::eWhile, tok1));
|
||||
tok = tok1;
|
||||
scope = &scopeList.back();
|
||||
scope->nestedIn->nestedList.push_back(scope);
|
||||
}
|
||||
else if (Token::simpleMatch(tok, "do {"))
|
||||
{
|
||||
scope = new Scope(this, tok, scope, Scope::eDo, tok->next());
|
||||
tok = tok->next();
|
||||
scopeList.push_back(scope);
|
||||
const Token *tok1 = tok->next();
|
||||
scopeList.push_back(Scope(this, tok, scope, Scope::eDo, tok1));
|
||||
tok = tok1;
|
||||
scope = &scopeList.back();
|
||||
scope->nestedIn->nestedList.push_back(scope);
|
||||
}
|
||||
else if (Token::simpleMatch(tok, "switch (") &&
|
||||
Token::simpleMatch(tok->next()->link(), ") {"))
|
||||
{
|
||||
scope = new Scope(this, tok, scope, Scope::eSwitch, tok->next()->link()->next());
|
||||
tok = tok->next()->link()->next();
|
||||
scopeList.push_back(scope);
|
||||
const Token *tok1 = tok->next()->link()->next();
|
||||
scopeList.push_back(Scope(this, tok, scope, Scope::eSwitch, tok1));
|
||||
tok = tok1;
|
||||
scope = &scopeList.back();
|
||||
scope->nestedIn->nestedList.push_back(scope);
|
||||
}
|
||||
else if (tok->str() == "{")
|
||||
{
|
||||
if (!Token::Match(tok->previous(), "=|,|{"))
|
||||
{
|
||||
scope = new Scope(this, tok, scope, Scope::eUnconditional, tok);
|
||||
scopeList.push_back(scope);
|
||||
scopeList.push_back(Scope(this, tok, scope, Scope::eUnconditional, tok));
|
||||
scope = &scopeList.back();
|
||||
scope->nestedIn->nestedList.push_back(scope);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -468,12 +541,12 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
}
|
||||
}
|
||||
|
||||
std::list<Scope *>::iterator it;
|
||||
std::list<Scope>::iterator it;
|
||||
|
||||
// fill in base class info
|
||||
for (it = scopeList.begin(); it != scopeList.end(); ++it)
|
||||
{
|
||||
scope = *it;
|
||||
scope = &(*it);
|
||||
|
||||
// skip namespaces and functions
|
||||
if (!scope->isClassOrStruct())
|
||||
|
@ -482,11 +555,11 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
// finish filling in base class info
|
||||
for (unsigned int i = 0; i < scope->derivedFrom.size(); ++i)
|
||||
{
|
||||
std::list<Scope *>::iterator it1;
|
||||
std::list<Scope>::iterator it1;
|
||||
|
||||
for (it1 = scopeList.begin(); it1 != scopeList.end(); ++it1)
|
||||
{
|
||||
Scope *scope1 = *it1;
|
||||
Scope *scope1 = &(*it1);
|
||||
|
||||
/** @todo handle derived base classes and namespaces */
|
||||
if (scope1->type == Scope::eClass || scope1->type == Scope::eStruct)
|
||||
|
@ -512,7 +585,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
// fill in variable info
|
||||
for (it = scopeList.begin(); it != scopeList.end(); ++it)
|
||||
{
|
||||
scope = *it;
|
||||
scope = &(*it);
|
||||
|
||||
// find variables
|
||||
scope->getVariableList();
|
||||
|
@ -521,7 +594,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
// fill in function arguments
|
||||
for (it = scopeList.begin(); it != scopeList.end(); ++it)
|
||||
{
|
||||
scope = *it;
|
||||
scope = &(*it);
|
||||
|
||||
std::list<Function>::iterator func;
|
||||
|
||||
|
@ -542,7 +615,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
|
||||
for (it = scopeList.begin(); it != scopeList.end(); ++it)
|
||||
{
|
||||
scope = *it;
|
||||
scope = &(*it);
|
||||
|
||||
if (scope->isClassOrStruct() && scope->needInitialization == Scope::Unknown)
|
||||
{
|
||||
|
@ -624,7 +697,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
{
|
||||
for (it = scopeList.begin(); it != scopeList.end(); ++it)
|
||||
{
|
||||
scope = *it;
|
||||
scope = &(*it);
|
||||
|
||||
if (scope->isClassOrStruct() && scope->needInitialization == Scope::Unknown)
|
||||
debugMessage(scope->classDef, "SymbolDatabase::SymbolDatabase couldn't resolve all user defined types.");
|
||||
|
@ -638,7 +711,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
// check all scopes for variables
|
||||
for (it = scopeList.begin(); it != scopeList.end(); ++it)
|
||||
{
|
||||
scope = *it;
|
||||
scope = &(*it);
|
||||
|
||||
// add all variables
|
||||
std::list<Variable>::const_iterator var;
|
||||
|
@ -646,7 +719,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
{
|
||||
unsigned int varId = var->varId();
|
||||
if (varId)
|
||||
_variableList[varId] = &*var;
|
||||
_variableList[varId] = &(*var);
|
||||
}
|
||||
|
||||
// add all function paramaters
|
||||
|
@ -665,21 +738,13 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
{
|
||||
unsigned int varId = arg->varId();
|
||||
if (varId)
|
||||
_variableList[varId] = &*arg;
|
||||
_variableList[varId] = &(*arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SymbolDatabase::~SymbolDatabase()
|
||||
{
|
||||
std::list<Scope *>::iterator it;
|
||||
|
||||
for (it = scopeList.begin(); it != scopeList.end(); ++it)
|
||||
delete *it;
|
||||
}
|
||||
|
||||
bool SymbolDatabase::isFunction(const Token *tok, const Token **funcStart, const Token **argStart) const
|
||||
{
|
||||
// function returning function pointer? '... ( ... %var% ( ... ))( ... ) {'
|
||||
|
@ -826,12 +891,12 @@ void SymbolDatabase::addFunction(Scope **scope, const Token **tok, const Token *
|
|||
path_length++;
|
||||
}
|
||||
|
||||
std::list<Scope *>::iterator it1;
|
||||
std::list<Scope>::iterator it1;
|
||||
|
||||
// search for match
|
||||
for (it1 = scopeList.begin(); it1 != scopeList.end(); ++it1)
|
||||
{
|
||||
Scope *scope1 = *it1;
|
||||
Scope *scope1 = &(*it1);
|
||||
|
||||
bool match = false;
|
||||
if (scope1->className == tok1->str() && (scope1->type != Scope::eFunction))
|
||||
|
@ -923,6 +988,8 @@ void SymbolDatabase::addFunction(Scope **scope, const Token **tok, const Token *
|
|||
if (*scope)
|
||||
{
|
||||
(*scope)->functionOf = scope1;
|
||||
(*scope)->function = &scope1->functionList.back();
|
||||
|
||||
added = true;
|
||||
}
|
||||
break;
|
||||
|
@ -940,7 +1007,8 @@ void SymbolDatabase::addFunction(Scope **scope, const Token **tok, const Token *
|
|||
void SymbolDatabase::addNewFunction(Scope **scope, const Token **tok)
|
||||
{
|
||||
const Token *tok1 = *tok;
|
||||
Scope *new_scope = new Scope(this, tok1, *scope);
|
||||
scopeList.push_back(Scope(this, tok1, *scope));
|
||||
Scope *new_scope = &scopeList.back();
|
||||
|
||||
// skip to start of function
|
||||
while (tok1 && tok1->str() != "{")
|
||||
|
@ -954,8 +1022,7 @@ void SymbolDatabase::addNewFunction(Scope **scope, const Token **tok)
|
|||
// syntax error?
|
||||
if (!new_scope->classEnd)
|
||||
{
|
||||
(*scope)->nestedList.pop_back();
|
||||
delete new_scope;
|
||||
scopeList.pop_back();
|
||||
while (tok1->next())
|
||||
tok1 = tok1->next();
|
||||
*scope = NULL;
|
||||
|
@ -964,16 +1031,12 @@ void SymbolDatabase::addNewFunction(Scope **scope, const Token **tok)
|
|||
}
|
||||
|
||||
*scope = new_scope;
|
||||
|
||||
// add space
|
||||
scopeList.push_back(new_scope);
|
||||
|
||||
*tok = tok1;
|
||||
(*scope)->nestedIn->nestedList.push_back(*scope);
|
||||
}
|
||||
else
|
||||
{
|
||||
(*scope)->nestedList.pop_back();
|
||||
delete new_scope;
|
||||
scopeList.pop_back();
|
||||
*scope = NULL;
|
||||
*tok = NULL;
|
||||
}
|
||||
|
@ -1206,9 +1269,9 @@ Scope::Scope(SymbolDatabase *check_, const Token *classDef_, Scope *nestedIn_, S
|
|||
access(Public),
|
||||
numConstructors(0),
|
||||
needInitialization(Scope::Unknown),
|
||||
functionOf(NULL)
|
||||
functionOf(NULL),
|
||||
function(NULL)
|
||||
{
|
||||
nestedIn->nestedList.push_back(this);
|
||||
}
|
||||
|
||||
Scope::Scope(SymbolDatabase *check_, const Token *classDef_, Scope *nestedIn_) :
|
||||
|
@ -1219,7 +1282,8 @@ Scope::Scope(SymbolDatabase *check_, const Token *classDef_, Scope *nestedIn_) :
|
|||
nestedIn(nestedIn_),
|
||||
numConstructors(0),
|
||||
needInitialization(Scope::Unknown),
|
||||
functionOf(NULL)
|
||||
functionOf(NULL),
|
||||
function(NULL)
|
||||
{
|
||||
if (!classDef)
|
||||
{
|
||||
|
@ -1256,9 +1320,6 @@ Scope::Scope(SymbolDatabase *check_, const Token *classDef_, Scope *nestedIn_) :
|
|||
className = classDef->str();
|
||||
access = Public;
|
||||
}
|
||||
|
||||
if (nestedIn)
|
||||
nestedIn->nestedList.push_back(this);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1587,12 +1648,10 @@ bool Scope::findClosingBracket(const Token* tok, const Token*& close) const
|
|||
|
||||
const Scope *SymbolDatabase::findVariableType(const Scope *start, const Token *type) const
|
||||
{
|
||||
std::list<Scope *>::const_iterator it;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (it = scopeList.begin(); it != scopeList.end(); ++it)
|
||||
for (scope = scopeList.begin(); scope != scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *scope = *it;
|
||||
|
||||
// skip namespaces and functions
|
||||
if (scope->type == Scope::eNamespace || scope->type == Scope::eFunction || scope->type == Scope::eGlobal)
|
||||
continue;
|
||||
|
@ -1610,14 +1669,14 @@ const Scope *SymbolDatabase::findVariableType(const Scope *start, const Token *t
|
|||
parent = parent->nestedIn;
|
||||
|
||||
if (scope->nestedIn == parent)
|
||||
return scope;
|
||||
return &(*scope);
|
||||
}
|
||||
|
||||
// type has a namespace
|
||||
else
|
||||
{
|
||||
// FIXME check if namespace path matches supplied path
|
||||
return scope;
|
||||
return &(*scope);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1629,14 +1688,14 @@ const Scope *SymbolDatabase::findVariableType(const Scope *start, const Token *t
|
|||
|
||||
const Scope *SymbolDatabase::findFunctionScopeByToken(const Token *tok) const
|
||||
{
|
||||
std::list<Scope *>::const_iterator scope;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (scope = scopeList.begin(); scope != scopeList.end(); ++scope)
|
||||
{
|
||||
if ((*scope)->type == Scope::eFunction)
|
||||
if (scope->type == Scope::eFunction)
|
||||
{
|
||||
if ((*scope)->classDef == tok)
|
||||
return (*scope);
|
||||
if (scope->classDef == tok)
|
||||
return &(*scope);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -1646,16 +1705,16 @@ const Scope *SymbolDatabase::findFunctionScopeByToken(const Token *tok) const
|
|||
|
||||
const Function *SymbolDatabase::findFunctionByToken(const Token *tok) const
|
||||
{
|
||||
std::list<Scope *>::const_iterator scope;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (scope = scopeList.begin(); scope != scopeList.end(); ++scope)
|
||||
{
|
||||
std::list<Function>::const_iterator func;
|
||||
|
||||
for (func = (*scope)->functionList.begin(); func != (*scope)->functionList.end(); ++func)
|
||||
for (func = scope->functionList.begin(); func != scope->functionList.end(); ++func)
|
||||
{
|
||||
if (func->token == tok)
|
||||
return &*func;
|
||||
return &(*func);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -1704,7 +1763,7 @@ const Function *Scope::getDestructor() const
|
|||
for (it = functionList.begin(); it != functionList.end(); ++it)
|
||||
{
|
||||
if (it->type == Function::eDestructor)
|
||||
return &*it;
|
||||
return &(*it);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -400,7 +400,11 @@ public:
|
|||
AccessControl access;
|
||||
unsigned int numConstructors;
|
||||
NeedInitialization needInitialization;
|
||||
Scope *functionOf; // class/struct this function belongs to
|
||||
std::list<const Token *> usingList;
|
||||
|
||||
// function specific fields
|
||||
Scope *functionOf; // scope this function belongs to
|
||||
Function *function; // function info for this function
|
||||
|
||||
bool isClassOrStruct() const
|
||||
{
|
||||
|
@ -413,6 +417,7 @@ public:
|
|||
type == eFor || type == eWhile || type == eDo ||
|
||||
type == eSwitch || type == eUnconditional);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief find if name is in nested list
|
||||
* @param name name of nested scope
|
||||
|
@ -479,10 +484,9 @@ class SymbolDatabase
|
|||
{
|
||||
public:
|
||||
SymbolDatabase(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger);
|
||||
~SymbolDatabase();
|
||||
|
||||
/** @brief Information about all namespaces/classes/structrues */
|
||||
std::list<Scope *> scopeList;
|
||||
std::list<Scope> scopeList;
|
||||
|
||||
/**
|
||||
* @brief find a variable type if it's a user defined type
|
||||
|
|
|
@ -3504,6 +3504,19 @@ void Tokenizer::setVarId()
|
|||
}
|
||||
}
|
||||
|
||||
// Don't set variable id for 'AAA a[0] = 0;' declaration (#2638)
|
||||
if (tok2->previous()->varId() && tok2->str() == "[")
|
||||
{
|
||||
const Token *tok3 = tok2;
|
||||
while (tok3 && tok3->str() == "[")
|
||||
{
|
||||
tok3 = tok3->link();
|
||||
tok3 = tok3 ? tok3->next() : NULL;
|
||||
}
|
||||
if (Token::Match(tok3, "= !!{"))
|
||||
continue;
|
||||
}
|
||||
|
||||
// Variable declaration found => Set variable ids
|
||||
if (Token::Match(tok2, "[,();[=]") && !varname.empty())
|
||||
{
|
||||
|
@ -8131,12 +8144,10 @@ const Token *Tokenizer::getFunctionTokenByName(const char funcname[]) const
|
|||
{
|
||||
getSymbolDatabase();
|
||||
|
||||
std::list<Scope *>::const_iterator i;
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (i = _symbolDatabase->scopeList.begin(); i != _symbolDatabase->scopeList.end(); ++i)
|
||||
for (scope = _symbolDatabase->scopeList.begin(); scope != _symbolDatabase->scopeList.end(); ++scope)
|
||||
{
|
||||
const Scope *scope = *i;
|
||||
|
||||
if (scope->type == Scope::eFunction)
|
||||
{
|
||||
if (scope->classDef->str() == funcname)
|
||||
|
@ -8723,6 +8734,9 @@ void Tokenizer::simplifyComparisonOrder()
|
|||
{
|
||||
if (!tok->next()->isName() && !tok->next()->isNumber())
|
||||
continue;
|
||||
const Token *operand2 = tok->tokAt(3);
|
||||
if (!operand2->isName() && !operand2->isNumber())
|
||||
continue;
|
||||
const std::string op1(tok->strAt(1));
|
||||
tok->next()->str(tok->strAt(3));
|
||||
tok->tokAt(3)->str(op1);
|
||||
|
|
|
@ -309,6 +309,7 @@ Directory name is matched to all parts of the path.</para>
|
|||
<listitem>
|
||||
<para>Suppress a specific warning. The format of <spec> is: [error id]:[filename]:[line].
|
||||
The [filename] and [line] are optional.
|
||||
[error id] may be * to suppress all warnings (for a specified file or files).
|
||||
[filename] may contain the wildcard characters * or ?.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
|
|
@ -384,7 +384,8 @@ gui/test.cpp,16,error,mismatchAllocDealloc,Mismatching allocation and deallocati
|
|||
<para>The <literal>error id</literal> is the id that you want to suppress.
|
||||
The easiest way to get it is to use the <literal>--xml</literal> command
|
||||
line flag. Copy and paste the <literal>id</literal> string from the XML
|
||||
output.</para>
|
||||
output. This may be * to suppress all warnings (for a specified file or
|
||||
files).</para>
|
||||
|
||||
<para>The <literal>filename</literal> may include the wildcard characters
|
||||
* or ?, which match any sequence of characters or any single character
|
||||
|
|
|
@ -198,7 +198,8 @@ private:
|
|||
TEST_CASE(terminateStrncpy3);
|
||||
TEST_CASE(recursive_long_time);
|
||||
|
||||
TEST_CASE(crash); // Ticket #1587 - crash
|
||||
TEST_CASE(crash1); // Ticket #1587 - crash
|
||||
TEST_CASE(crash2); // Ticket #2607 - crash
|
||||
|
||||
TEST_CASE(executionPaths1);
|
||||
TEST_CASE(executionPaths2);
|
||||
|
@ -210,6 +211,8 @@ private:
|
|||
TEST_CASE(scope); // handling different scopes
|
||||
|
||||
TEST_CASE(getErrorMessages);
|
||||
|
||||
TEST_CASE(unknownMacroNoDecl); // #2638 - not variable declaration: 'AAA a[0] = 0;'
|
||||
}
|
||||
|
||||
|
||||
|
@ -2709,7 +2712,7 @@ private:
|
|||
|
||||
|
||||
// Ticket #1587 - crash
|
||||
void crash()
|
||||
void crash1()
|
||||
{
|
||||
check("struct struct A\n"
|
||||
"{\n"
|
||||
|
@ -2724,6 +2727,10 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void crash2()
|
||||
{
|
||||
check("struct C {} {} x");
|
||||
}
|
||||
|
||||
|
||||
void epcheck(const char code[])
|
||||
|
@ -2936,6 +2943,16 @@ private:
|
|||
CheckBufferOverrun c;
|
||||
c.getErrorMessages(this, 0);
|
||||
}
|
||||
|
||||
void unknownMacroNoDecl()
|
||||
{
|
||||
check("void f() {\n"
|
||||
" int a[10];\n"
|
||||
" AAA a[0] = 0;\n" // <- not a valid array declaration
|
||||
" a[1] = 1;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestBufferOverrun)
|
||||
|
|
|
@ -2962,18 +2962,6 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:9]: (error) Using 'memset' on class that contains a 'std::string'\n", errout.str());
|
||||
|
||||
checkNoMemset("struct Stringy {\n"
|
||||
" std::string inner;\n"
|
||||
"};\n"
|
||||
"struct Foo {\n"
|
||||
" Stringy s;\n"
|
||||
"};\n"
|
||||
"int main() {\n"
|
||||
" Foo foo;\n"
|
||||
" memset(&foo, 0, sizeof(Foo));\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:9]: (error) Using 'memset' on struct that contains a 'std::string'\n", errout.str());
|
||||
|
||||
checkNoMemset("class Fred\n"
|
||||
"{\n"
|
||||
" virtual ~Fred();\n"
|
||||
|
@ -2999,6 +2987,48 @@ private:
|
|||
" memset(&pebbles, 0, sizeof(pebbles));\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:12]: (error) Using 'memset' on class that contains a virtual method\n", errout.str());
|
||||
|
||||
// Fred not defined in scope
|
||||
checkNoMemset("namespace n1 {\n"
|
||||
" class Fred\n"
|
||||
" {\n"
|
||||
" std::string b; \n"
|
||||
" };\n"
|
||||
"}\n"
|
||||
"void f()\n"
|
||||
"{\n"
|
||||
" Fred fred;\n"
|
||||
" memset(&fred, 0, sizeof(Fred));\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// Fred with namespace qualifier
|
||||
checkNoMemset("namespace n1 {\n"
|
||||
" class Fred\n"
|
||||
" {\n"
|
||||
" std::string b; \n"
|
||||
" };\n"
|
||||
"}\n"
|
||||
"void f()\n"
|
||||
"{\n"
|
||||
" n1::Fred fred;\n"
|
||||
" memset(&fred, 0, sizeof(n1::Fred));\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:10]: (error) Using 'memset' on class that contains a 'std::string'\n", errout.str());
|
||||
|
||||
// Fred with namespace qualifier
|
||||
checkNoMemset("namespace n1 {\n"
|
||||
" class Fred\n"
|
||||
" {\n"
|
||||
" std::string b; \n"
|
||||
" };\n"
|
||||
"}\n"
|
||||
"void f()\n"
|
||||
"{\n"
|
||||
" n1::Fred fred;\n"
|
||||
" memset(&fred, 0, sizeof(fred));\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:10]: (error) Using 'memset' on class that contains a 'std::string'\n", errout.str());
|
||||
}
|
||||
|
||||
void memsetOnStruct()
|
||||
|
|
|
@ -46,6 +46,7 @@ private:
|
|||
TEST_CASE(nullpointer9);
|
||||
TEST_CASE(pointerCheckAndDeRef); // check if pointer is null and then dereference it
|
||||
TEST_CASE(nullConstantDereference); // Dereference NULL constant
|
||||
TEST_CASE(gcc_statement_expression); // Don't crash
|
||||
}
|
||||
|
||||
void check(const char code[])
|
||||
|
@ -326,6 +327,39 @@ private:
|
|||
" ;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #2641 - global pointer, function call
|
||||
check("ABC *abc;\n"
|
||||
"void f() {\n"
|
||||
" abc->a = 0;\n"
|
||||
" do_stuff();\n"
|
||||
" if (abc) { }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("",errout.str());
|
||||
|
||||
check("Fred *fred;\n"
|
||||
"void f() {\n"
|
||||
" fred->foo();\n"
|
||||
" if (fred) { }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("",errout.str());
|
||||
|
||||
// #2641 - local pointer, function call
|
||||
check("void f() {\n"
|
||||
" ABC *abc;\n"
|
||||
" abc->a = 0;\n"
|
||||
" do_stuff();\n"
|
||||
" if (abc) { }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Possible null pointer dereference: abc - otherwise it is redundant to check if abc is null at line 5\n",errout.str());
|
||||
|
||||
// #2641 - local pointer, function call
|
||||
check("void f(ABC *abc) {\n"
|
||||
" abc->a = 0;\n"
|
||||
" do_stuff();\n"
|
||||
" if (abc) { }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (error) Possible null pointer dereference: abc - otherwise it is redundant to check if abc is null at line 4\n",errout.str());
|
||||
}
|
||||
|
||||
// Dereferencing a pointer and then checking if it is null
|
||||
|
@ -970,6 +1004,14 @@ private:
|
|||
|
||||
}
|
||||
|
||||
void gcc_statement_expression()
|
||||
{
|
||||
// Ticket #2621
|
||||
check("void f(struct ABC *abc) {\n"
|
||||
" ({ if (abc) dbg(); })\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestNullPointer)
|
||||
|
|
|
@ -105,6 +105,8 @@ private:
|
|||
|
||||
TEST_CASE(clarifyCalculation);
|
||||
|
||||
TEST_CASE(clarifyCondition); // if (a = b() < 0)
|
||||
|
||||
TEST_CASE(incorrectStringCompare);
|
||||
|
||||
TEST_CASE(incrementBoolean);
|
||||
|
@ -131,6 +133,7 @@ private:
|
|||
checkOther.checkRedundantAssignmentInSwitch();
|
||||
checkOther.checkAssignmentInAssert();
|
||||
checkOther.checkSizeofForArrayParameter();
|
||||
checkOther.clarifyCondition();
|
||||
|
||||
// Simplify token list..
|
||||
tokenizer.simplifyTokenList();
|
||||
|
@ -544,7 +547,7 @@ private:
|
|||
" for ( ; i < 10; ++i) ;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (information) The scope of the variable i can be reduced\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (information) The scope of the variable 'i' can be reduced\n", errout.str());
|
||||
|
||||
varScope("void f(int x)\n"
|
||||
"{\n"
|
||||
|
@ -554,7 +557,7 @@ private:
|
|||
" for ( ; i < 10; ++i) ;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (information) The scope of the variable i can be reduced\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (information) The scope of the variable 'i' can be reduced\n", errout.str());
|
||||
}
|
||||
|
||||
void varScope6()
|
||||
|
@ -620,7 +623,7 @@ private:
|
|||
" edgeResistance = (edge+1) / 2.0;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (information) The scope of the variable edgeResistance can be reduced\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:2]: (information) The scope of the variable 'edgeResistance' can be reduced\n", errout.str());
|
||||
}
|
||||
|
||||
void varScope9()
|
||||
|
@ -1177,6 +1180,22 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo()\n"
|
||||
"{\n"
|
||||
" int y = 1;\n"
|
||||
" while(xyz()) {\n"
|
||||
" switch (x)\n"
|
||||
" {\n"
|
||||
" case 2:\n"
|
||||
" y = 2;\n"
|
||||
" throw e;\n"
|
||||
" case 3:\n"
|
||||
" y = 3;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo()\n"
|
||||
"{\n"
|
||||
" int y = 1;\n"
|
||||
|
@ -1219,6 +1238,27 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check_preprocess_suppress(
|
||||
"void foo() {\n"
|
||||
" switch (a) {\n"
|
||||
" case 1:\n"
|
||||
" break;\n"
|
||||
" case 2:\n"
|
||||
" continue;\n"
|
||||
" case 3:\n"
|
||||
" return;\n"
|
||||
" case 4:\n"
|
||||
" exit(1);\n"
|
||||
" case 5:\n"
|
||||
" goto end;\n"
|
||||
" case 6:\n"
|
||||
" throw e;\n"
|
||||
" case 7:\n"
|
||||
" break;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check_preprocess_suppress(
|
||||
"void foo() {\n"
|
||||
" switch (a) {\n"
|
||||
|
@ -1734,6 +1774,15 @@ private:
|
|||
|
||||
check(code, "test.c");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// Ticket #2639
|
||||
check("struct stat { int a; int b; };\n"
|
||||
"void stat(const char *fn, struct stat *);\n"
|
||||
"\n"
|
||||
"void foo() {\n"
|
||||
" stat(\"file.txt\", &st);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("",errout.str());
|
||||
}
|
||||
|
||||
void testMisusedScopeObjectDoesNotPickNestedClass()
|
||||
|
@ -2206,12 +2255,12 @@ private:
|
|||
check("int f(char c) {\n"
|
||||
" return 10 * (c == 0) ? 1 : 2;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (information) Please clarify precedence: 'a*b?..'\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:2]: (style) Please clarify precedence: 'a*b?..'\n", errout.str());
|
||||
|
||||
check("void f(char c) {\n"
|
||||
" printf(\"%i\", 10 * (c == 0) ? 1 : 2);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (information) Please clarify precedence: 'a*b?..'\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:2]: (style) Please clarify precedence: 'a*b?..'\n", errout.str());
|
||||
|
||||
// Ticket #2585 - segmentation fault for invalid code
|
||||
check("abcdef?" "?<"
|
||||
|
@ -2220,6 +2269,15 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// clarify conditions with = and comparison
|
||||
void clarifyCondition()
|
||||
{
|
||||
check("void f() {\n"
|
||||
" if (x = b() < 0) {}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (style) Suspicious condition (assignment+comparison), it can be clarified with parantheses\n", errout.str());
|
||||
}
|
||||
|
||||
void incorrectStringCompare()
|
||||
{
|
||||
check("int f() {\n"
|
||||
|
|
|
@ -102,6 +102,7 @@ private:
|
|||
TEST_CASE(missingInnerComparison3); // no FP when there is iterator shadowing
|
||||
TEST_CASE(missingInnerComparison4); // no FP when "break;" is used
|
||||
TEST_CASE(missingInnerComparison5); // Ticket #2154 - FP
|
||||
TEST_CASE(missingInnerComparison6); // #2643 - 'it=foo.insert(++it,0);'
|
||||
|
||||
// catch common problems when using the string::c_str() function
|
||||
TEST_CASE(cstr);
|
||||
|
@ -1250,6 +1251,16 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void missingInnerComparison6()
|
||||
{
|
||||
check("void f(std::string &s) {\n"
|
||||
" for(string::iterator it = s.begin(); it != s.end(); it++) {\n"
|
||||
" it = s.insert(++it, 0);\n"
|
||||
" }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void cstr()
|
||||
{
|
||||
check("void f() {\n"
|
||||
|
|
|
@ -48,7 +48,10 @@ private:
|
|||
Settings settings;
|
||||
settings._inlineSuppressions = true;
|
||||
if (!suppression.empty())
|
||||
settings.nomsg.addSuppressionLine(suppression);
|
||||
{
|
||||
std::string r = settings.nomsg.addSuppressionLine(suppression);
|
||||
ASSERT_EQUALS("", r);
|
||||
}
|
||||
|
||||
CppCheck cppCheck(*this, true);
|
||||
cppCheck.settings(settings);
|
||||
|
@ -75,7 +78,10 @@ private:
|
|||
settings._jobs = 1;
|
||||
settings._inlineSuppressions = true;
|
||||
if (!suppression.empty())
|
||||
settings.nomsg.addSuppressionLine(suppression);
|
||||
{
|
||||
std::string r = settings.nomsg.addSuppressionLine(suppression);
|
||||
ASSERT_EQUALS("", r);
|
||||
}
|
||||
ThreadExecutor executor(filenames, settings, *this);
|
||||
for (unsigned int i = 0; i < filenames.size(); ++i)
|
||||
executor.addFileContent(filenames[i], code);
|
||||
|
@ -147,6 +153,22 @@ private:
|
|||
"uninitvar:test.cpp");
|
||||
ASSERT_EQUALS("[test.cpp]: (information) Unmatched suppression: uninitvar\n", errout.str());
|
||||
|
||||
// suppress all for this file only
|
||||
(this->*check)("void f() {\n"
|
||||
" int a;\n"
|
||||
" a++;\n"
|
||||
"}\n",
|
||||
"*:test.cpp");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// suppress all for this file only, without error present
|
||||
(this->*check)("void f() {\n"
|
||||
" int a;\n"
|
||||
" b++;\n"
|
||||
"}\n",
|
||||
"*:test.cpp");
|
||||
ASSERT_EQUALS("[test.cpp]: (information) Unmatched suppression: *\n", errout.str());
|
||||
|
||||
// suppress uninitvar for this file and line
|
||||
(this->*check)("void f() {\n"
|
||||
" int a;\n"
|
||||
|
|
|
@ -558,11 +558,11 @@ private:
|
|||
ASSERT(db && db->scopeList.size() == 1);
|
||||
if (db && db->scopeList.size() == 1)
|
||||
{
|
||||
std::list<Scope *>::const_iterator it = db->scopeList.begin();
|
||||
ASSERT((*it)->varlist.size() == 1);
|
||||
if ((*it)->varlist.size() == 1)
|
||||
std::list<Scope>::const_iterator it = db->scopeList.begin();
|
||||
ASSERT(it->varlist.size() == 1);
|
||||
if (it->varlist.size() == 1)
|
||||
{
|
||||
std::list<Variable>::const_iterator var = (*it)->varlist.begin();
|
||||
std::list<Variable>::const_iterator var = it->varlist.begin();
|
||||
ASSERT(var->name() == "i");
|
||||
ASSERT(var->typeStartToken()->str() == "int");
|
||||
}
|
||||
|
@ -576,11 +576,11 @@ private:
|
|||
ASSERT(db && db->scopeList.size() == 1);
|
||||
if (db && db->scopeList.size() == 1)
|
||||
{
|
||||
std::list<Scope *>::const_iterator it = db->scopeList.begin();
|
||||
ASSERT((*it)->varlist.size() == 1);
|
||||
if ((*it)->varlist.size() == 1)
|
||||
std::list<Scope>::const_iterator it = db->scopeList.begin();
|
||||
ASSERT(it->varlist.size() == 1);
|
||||
if (it->varlist.size() == 1)
|
||||
{
|
||||
std::list<Variable>::const_iterator var = (*it)->varlist.begin();
|
||||
std::list<Variable>::const_iterator var = it->varlist.begin();
|
||||
ASSERT(var->name() == "array");
|
||||
ASSERT(var->typeStartToken()->str() == "int");
|
||||
}
|
||||
|
@ -594,11 +594,11 @@ private:
|
|||
ASSERT(db && db->scopeList.size() == 1);
|
||||
if (db && db->scopeList.size() == 1)
|
||||
{
|
||||
std::list<Scope *>::const_iterator it = db->scopeList.begin();
|
||||
ASSERT((*it)->varlist.size() == 1);
|
||||
if ((*it)->varlist.size() == 1)
|
||||
std::list<Scope>::const_iterator it = db->scopeList.begin();
|
||||
ASSERT(it->varlist.size() == 1);
|
||||
if (it->varlist.size() == 1)
|
||||
{
|
||||
std::list<Variable>::const_iterator var = (*it)->varlist.begin();
|
||||
std::list<Variable>::const_iterator var = it->varlist.begin();
|
||||
ASSERT(var->name() == "array");
|
||||
ASSERT(var->typeStartToken()->str() == "int");
|
||||
}
|
||||
|
|
|
@ -181,6 +181,7 @@ private:
|
|||
TEST_CASE(varid_in_class2);
|
||||
TEST_CASE(varid_operator);
|
||||
TEST_CASE(varid_throw);
|
||||
TEST_CASE(varid_unknown_macro); // #2638 - unknown macro is not type
|
||||
|
||||
TEST_CASE(varidclass1);
|
||||
TEST_CASE(varidclass2);
|
||||
|
@ -3133,6 +3134,23 @@ private:
|
|||
ASSERT_EQUALS(expected, actual);
|
||||
}
|
||||
|
||||
void varid_unknown_macro()
|
||||
{
|
||||
// #2638 - unknown macro
|
||||
const char code[] = "void f() {\n"
|
||||
" int a[10];\n"
|
||||
" AAA\n"
|
||||
" a[0] = 0;\n"
|
||||
"}";
|
||||
const char expected[] = "\n\n##file 0\n"
|
||||
"1: void f ( ) {\n"
|
||||
"2: int a@1 [ 10 ] ;\n"
|
||||
"3: AAA\n"
|
||||
"4: a@1 [ 0 ] = 0 ;\n"
|
||||
"5: }\n";
|
||||
ASSERT_EQUALS(expected, tokenizeDebugListing(code));
|
||||
}
|
||||
|
||||
void varidclass1()
|
||||
{
|
||||
const std::string actual = tokenizeDebugListing(
|
||||
|
@ -4598,6 +4616,8 @@ private:
|
|||
{
|
||||
ASSERT_EQUALS("( i < 10 )", tokenizeAndStringify("(10>i)"));
|
||||
ASSERT_EQUALS("; i < 10 ;", tokenizeAndStringify(";10>i;"));
|
||||
ASSERT_EQUALS("void > ( ) ; void > ( )",
|
||||
tokenizeAndStringify("void>(); void>()"));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,259 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{474ff42a-e7a3-42dc-a618-153c6c6c9127}</ProjectGuid>
|
||||
<Config Condition="'$(Config)'==''">Debug</Config>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''">
|
||||
<Base>true</Base>
|
||||
<Cfg_1>true</Cfg_1>
|
||||
<CfgParent>Base</CfgParent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_2)'!=''">
|
||||
<Base>true</Base>
|
||||
<Cfg_2>true</Cfg_2>
|
||||
<CfgParent>Base</CfgParent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Base)'!=''">
|
||||
<BCC_OptimizeForSpeed>true</BCC_OptimizeForSpeed>
|
||||
<OutputExt>exe</OutputExt>
|
||||
<Defines>NO_STRICT</Defines>
|
||||
<DCC_CBuilderOutput>JPHNE</DCC_CBuilderOutput>
|
||||
<DynamicRTL>true</DynamicRTL>
|
||||
<UsePackages>true</UsePackages>
|
||||
<ILINK_ObjectSearchPath>C:\cppcheck;test;src;lib;test\tinyxml;cli</ILINK_ObjectSearchPath>
|
||||
<ProjectType>CppConsoleApplication</ProjectType>
|
||||
<NoVCL>true</NoVCL>
|
||||
<FinalOutputDir>.</FinalOutputDir>
|
||||
<PackageImports>vclx.bpi;vcl.bpi;rtl.bpi;vclactnband.bpi</PackageImports>
|
||||
<BCC_wpar>false</BCC_wpar>
|
||||
<IncludePath>$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;C:\cppcheck;test;src;lib;test\tinyxml;cli</IncludePath>
|
||||
<ILINK_LibraryPath>$(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;C:\cppcheck;test;src;lib;test\tinyxml;cli</ILINK_LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_1)'!=''">
|
||||
<DCC_Optimize>false</DCC_Optimize>
|
||||
<BCC_OptimizeForSpeed>false</BCC_OptimizeForSpeed>
|
||||
<Defines>_DEBUG;_HAS_ITERATOR_DEBUGGING=1;$(Defines)</Defines>
|
||||
<DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>
|
||||
<ILINK_FullDebugInfo>true</ILINK_FullDebugInfo>
|
||||
<BCC_InlineFunctionExpansion>false</BCC_InlineFunctionExpansion>
|
||||
<ILINK_DisableIncrementalLinking>true</ILINK_DisableIncrementalLinking>
|
||||
<BCC_UseRegisterVariables>None</BCC_UseRegisterVariables>
|
||||
<DCC_Define>DEBUG</DCC_Define>
|
||||
<BCC_DebugLineNumbers>true</BCC_DebugLineNumbers>
|
||||
<FinalOutputDir>bcb_debug</FinalOutputDir>
|
||||
<IntermediateOutputDir>bcb_Debug</IntermediateOutputDir>
|
||||
<TASM_DisplaySourceLines>true</TASM_DisplaySourceLines>
|
||||
<BCC_StackFrames>true</BCC_StackFrames>
|
||||
<ILINK_LibraryPath>$(BDS)\lib\debug;$(ILINK_LibraryPath)</ILINK_LibraryPath>
|
||||
<BCC_DisableOptimizations>true</BCC_DisableOptimizations>
|
||||
<TASM_Debugging>Full</TASM_Debugging>
|
||||
<BCC_SourceDebuggingOn>true</BCC_SourceDebuggingOn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_2)'!=''">
|
||||
<Defines>NDEBUG;$(Defines)</Defines>
|
||||
<IntermediateOutputDir>Release</IntermediateOutputDir>
|
||||
<ILINK_LibraryPath>$(BDS)\lib\release;$(ILINK_LibraryPath)</ILINK_LibraryPath>
|
||||
<TASM_Debugging>None</TASM_Debugging>
|
||||
</PropertyGroup>
|
||||
<ProjectExtensions>
|
||||
<Borland.Personality>CPlusPlusBuilder.Personality</Borland.Personality>
|
||||
<Borland.ProjectType>CppConsoleApplication</Borland.ProjectType>
|
||||
<BorlandProject>
|
||||
<BorlandProject><CPlusPlusBuilder.Personality><VersionInfo><VersionInfo Name="IncludeVerInfo">False</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">1</VersionInfo><VersionInfo Name="MinorVer">0</VersionInfo><VersionInfo Name="Release">0</VersionInfo><VersionInfo Name="Build">0</VersionInfo><VersionInfo Name="Debug">False</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">1053</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName"></VersionInfoKeys><VersionInfoKeys Name="FileDescription"></VersionInfoKeys><VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName"></VersionInfoKeys><VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="Comments"></VersionInfoKeys></VersionInfoKeys><Debugging><Debugging Name="DebugSourceDirs"></Debugging></Debugging><Parameters><Parameters Name="RunParams"></Parameters><Parameters Name="Launcher"></Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="DebugCWD"></Parameters><Parameters Name="HostApplication"></Parameters><Parameters Name="RemoteHost"></Parameters><Parameters Name="RemotePath"></Parameters><Parameters Name="RemoteParams"></Parameters><Parameters Name="RemoteLauncher"></Parameters><Parameters Name="UseRemoteLauncher">False</Parameters><Parameters Name="RemoteCWD"></Parameters><Parameters Name="RemoteDebug">False</Parameters><Parameters Name="Debug Symbols Search Path"></Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters></Parameters><Excluded_Packages>
|
||||
|
||||
|
||||
<Excluded_Packages Name="C:\Documents and Settings\All Users\Documents\RAD Studio\5.0\BPL\A407_D110.bpl">TurboPower Async Professional 4.07 Designtime Package - VCL110</Excluded_Packages>
|
||||
<Excluded_Packages Name="C:\Documents and Settings\All Users\Documents\RAD Studio\5.0\BPL\DreamEdit_C6.bpl">Dream Editor Package</Excluded_Packages>
|
||||
</Excluded_Packages><Linker><Linker Name="LibPrefix"></Linker><Linker Name="LibSuffix"></Linker><Linker Name="LibVersion"></Linker></Linker><ProjectProperties><ProjectProperties Name="AutoShowDeps">False</ProjectProperties><ProjectProperties Name="ManagePaths">True</ProjectProperties><ProjectProperties Name="VerifyPackages">True</ProjectProperties></ProjectProperties><HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name="Count">2</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name="Item0">$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;C:\cppcheck;test;src;lib</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name="Item1">$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;C:\cppcheck</HistoryLists_hlIncludePath></HistoryLists_hlIncludePath><HistoryLists_hlFinalOutputDir><HistoryLists_hlFinalOutputDir Name="Count">2</HistoryLists_hlFinalOutputDir><HistoryLists_hlFinalOutputDir Name="Item0">bcb_debug</HistoryLists_hlFinalOutputDir><HistoryLists_hlFinalOutputDir Name="Item1">.</HistoryLists_hlFinalOutputDir></HistoryLists_hlFinalOutputDir><HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name="Count">1</HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name="Item0">$(BDS)\lib\debug;$(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;C:\cppcheck;test;src;lib</HistoryLists_hlILINK_LibraryPath></HistoryLists_hlILINK_LibraryPath><HistoryLists_hlDefines><HistoryLists_hlDefines Name="Count">1</HistoryLists_hlDefines><HistoryLists_hlDefines Name="Item0">_DEBUG;NO_STRICT;_HAS_ITERATOR_DEBUGGING=1</HistoryLists_hlDefines></HistoryLists_hlDefines><HistoryLists_hlIntermediateOutputDir><HistoryLists_hlIntermediateOutputDir Name="Count">1</HistoryLists_hlIntermediateOutputDir><HistoryLists_hlIntermediateOutputDir Name="Item0">bcb_Debug</HistoryLists_hlIntermediateOutputDir></HistoryLists_hlIntermediateOutputDir></CPlusPlusBuilder.Personality></BorlandProject></BorlandProject>
|
||||
</ProjectExtensions>
|
||||
<Import Project="$(MSBuildBinPath)\Borland.Cpp.Targets" />
|
||||
<ItemGroup>
|
||||
<CppCompile Include="cli\threadexecutor.cpp">
|
||||
<BuildOrder>52</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkautovariables.cpp">
|
||||
<DependentOn>lib\checkautovariables.h</DependentOn>
|
||||
<BuildOrder>0</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkbufferoverrun.cpp">
|
||||
<DependentOn>lib\checkbufferoverrun.h</DependentOn>
|
||||
<BuildOrder>1</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkclass.cpp">
|
||||
<DependentOn>lib\checkclass.h</DependentOn>
|
||||
<BuildOrder>2</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkdangerousfunctions.cpp">
|
||||
<DependentOn>lib\checkdangerousfunctions.h</DependentOn>
|
||||
<BuildOrder>3</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkexceptionsafety.cpp">
|
||||
<DependentOn>lib\checkexceptionsafety.h</DependentOn>
|
||||
<BuildOrder>4</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkmemoryleak.cpp">
|
||||
<DependentOn>lib\checkmemoryleak.h</DependentOn>
|
||||
<BuildOrder>5</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkother.cpp">
|
||||
<DependentOn>lib\checkother.h</DependentOn>
|
||||
<BuildOrder>6</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkstl.cpp">
|
||||
<DependentOn>lib\checkstl.h</DependentOn>
|
||||
<BuildOrder>7</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\checkunusedfunctions.cpp">
|
||||
<DependentOn>lib\checkunusedfunctions.h</DependentOn>
|
||||
<BuildOrder>8</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\cppcheck.cpp">
|
||||
<BuildOrder>9</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\errorlogger.cpp">
|
||||
<DependentOn>lib\errorlogger.h</DependentOn>
|
||||
<BuildOrder>10</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\executionpath.cpp">
|
||||
<DependentOn>lib\executionpath.h</DependentOn>
|
||||
<BuildOrder>11</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\filelister.cpp">
|
||||
<DependentOn>lib\filelister.h</DependentOn>
|
||||
<BuildOrder>12</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\filelister_unix.cpp">
|
||||
<BuildOrder>13</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\filelister_win32.cpp">
|
||||
<BuildOrder>14</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\mathlib.cpp">
|
||||
<DependentOn>lib\mathlib.h</DependentOn>
|
||||
<BuildOrder>15</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\path.cpp">
|
||||
<BuildOrder>16</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\preprocessor.cpp">
|
||||
<DependentOn>lib\preprocessor.h</DependentOn>
|
||||
<BuildOrder>17</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\settings.cpp">
|
||||
<DependentOn>lib\settings.h</DependentOn>
|
||||
<BuildOrder>18</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\token.cpp">
|
||||
<DependentOn>lib\token.h</DependentOn>
|
||||
<BuildOrder>19</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="lib\tokenize.cpp">
|
||||
<DependentOn>lib\tokenize.h</DependentOn>
|
||||
<BuildOrder>20</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testautovariables.cpp">
|
||||
<BuildOrder>25</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testbufferoverrun.cpp">
|
||||
<BuildOrder>26</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testcharvar.cpp">
|
||||
<BuildOrder>27</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testclass.cpp">
|
||||
<BuildOrder>28</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testconstructors.cpp">
|
||||
<BuildOrder>29</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testcppcheck.cpp">
|
||||
<BuildOrder>30</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testdangerousfunctions.cpp">
|
||||
<BuildOrder>31</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testdivision.cpp">
|
||||
<BuildOrder>32</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testexceptionsafety.cpp">
|
||||
<BuildOrder>33</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testfilelister.cpp">
|
||||
<BuildOrder>34</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testincompletestatement.cpp">
|
||||
<BuildOrder>35</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testmathlib.cpp">
|
||||
<BuildOrder>36</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testmemleak.cpp">
|
||||
<BuildOrder>37</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testother.cpp">
|
||||
<BuildOrder>38</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testpreprocessor.cpp">
|
||||
<BuildOrder>39</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testredundantif.cpp">
|
||||
<BuildOrder>40</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testrunner.cpp">
|
||||
<BuildOrder>41</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testsettings.cpp">
|
||||
<BuildOrder>42</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testsimplifytokens.cpp">
|
||||
<BuildOrder>43</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\teststl.cpp">
|
||||
<BuildOrder>44</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testsuite.cpp">
|
||||
<DependentOn>test\testsuite.h</DependentOn>
|
||||
<BuildOrder>45</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testthreadexecutor.cpp">
|
||||
<BuildOrder>46</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testtoken.cpp">
|
||||
<BuildOrder>47</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testtokenize.cpp">
|
||||
<BuildOrder>48</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testunusedfunctions.cpp">
|
||||
<BuildOrder>49</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testunusedprivfunc.cpp">
|
||||
<BuildOrder>50</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\testunusedvar.cpp">
|
||||
<BuildOrder>51</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\tinyxml\tinystr.cpp">
|
||||
<BuildOrder>21</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\tinyxml\tinyxml.cpp">
|
||||
<BuildOrder>22</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\tinyxml\tinyxmlerror.cpp">
|
||||
<BuildOrder>23</BuildOrder>
|
||||
</CppCompile>
|
||||
<CppCompile Include="test\tinyxml\tinyxmlparser.cpp">
|
||||
<BuildOrder>24</BuildOrder>
|
||||
</CppCompile>
|
||||
<BuildConfiguration Include="Debug">
|
||||
<Key>Cfg_1</Key>
|
||||
</BuildConfiguration>
|
||||
<BuildConfiguration Include="Release">
|
||||
<Key>Cfg_2</Key>
|
||||
</BuildConfiguration>
|
||||
</ItemGroup>
|
||||
</Project>
|
21
webreport.sh
21
webreport.sh
|
@ -1,20 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
doxygen 2> htdocs/doxygen-errors.txt
|
||||
./generate_coverage_report
|
||||
rm -R coverage_report/bits
|
||||
rm -R coverage_report/ext
|
||||
rm -R coverage_report/home/daniel/cppcheck/test
|
||||
rm -R coverage_report/i486-linux-gnu
|
||||
rm -R coverage_report/usr
|
||||
|
||||
rm -R htdocs/doxyoutput
|
||||
rm -R htdocs/coverage_report
|
||||
rm -rf devinfo
|
||||
mkdir devinfo
|
||||
|
||||
mv doxyoutput/html htdocs/doxyoutput
|
||||
mv coverage_report htdocs/
|
||||
mv coverage_report devinfo/
|
||||
|
||||
doxygen 2> devinfo/doxygen-errors.txt
|
||||
mv doxyoutput/html devinfo/doxyoutput
|
||||
|
||||
# Detect duplicate code..
|
||||
~/pmd-4.2.5/bin/cpd.sh lib/ > htdocs/cpd.txt
|
||||
~/pmd-4.2.5/bin/cpd.sh lib/ > devinfo/cpd.txt
|
||||
|
||||
#scp -r devinfo/ hyd_danmar,cppcheck@web.sourceforge.net:/home/groups/c/cp/cppcheck/htdocs
|
||||
|
||||
scp -r htdocs hyd_danmar,cppcheck@web.sourceforge.net:/home/groups/c/cp/cppcheck/
|
||||
|
|
Loading…
Reference in New Issue