Merge branch 'master' of github.com:danmar/cppcheck
This commit is contained in:
commit
73e2a8fdb5
5
Makefile
5
Makefile
|
@ -180,10 +180,7 @@ TESTOBJ = test/options.o \
|
|||
test/testunusedvar.o
|
||||
|
||||
ifndef TINYXML
|
||||
TINYXML = externals/tinyxml/tinystr.o \
|
||||
externals/tinyxml/tinyxml.o \
|
||||
externals/tinyxml/tinyxmlerror.o \
|
||||
externals/tinyxml/tinyxmlparser.o
|
||||
TINYXML = externals/tinyxml/tinyxml2.o
|
||||
endif
|
||||
|
||||
|
||||
|
|
|
@ -357,8 +357,12 @@
|
|||
<ResourceCompile Include="version.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\externals\tinyxml\tinystr.h" />
|
||||
<ClInclude Include="..\externals\tinyxml\tinyxml.h" />
|
||||
<ClInclude Include="..\externals\tinyxml\tinyxml2.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\config.h" />
|
||||
<ClInclude Include="cmdlineparser.h" />
|
||||
<ClInclude Include="cppcheckexecutor.h" />
|
||||
|
@ -372,10 +376,12 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\externals\tinyxml\tinystr.cpp" />
|
||||
<ClCompile Include="..\externals\tinyxml\tinyxml.cpp" />
|
||||
<ClCompile Include="..\externals\tinyxml\tinyxmlerror.cpp" />
|
||||
<ClCompile Include="..\externals\tinyxml\tinyxmlparser.cpp" />
|
||||
<ClCompile Include="..\externals\tinyxml\tinyxml2.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="cmdlineparser.cpp" />
|
||||
<ClCompile Include="cppcheckexecutor.cpp" />
|
||||
<ClCompile Include="filelister.cpp" />
|
||||
|
|
|
@ -32,10 +32,7 @@
|
|||
<ClInclude Include="pathmatch.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\externals\tinyxml\tinystr.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\externals\tinyxml\tinyxml.h">
|
||||
<ClInclude Include="..\externals\tinyxml\tinyxml2.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
|
@ -58,16 +55,7 @@
|
|||
<ClCompile Include="cmdlineparser.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\externals\tinyxml\tinystr.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\externals\tinyxml\tinyxml.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\externals\tinyxml\tinyxmlerror.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\externals\tinyxml\tinyxmlparser.cpp">
|
||||
<ClCompile Include="..\externals\tinyxml\tinyxml2.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
#ifdef HAVE_RULES
|
||||
// xml is used in rules
|
||||
#include <tinyxml.h>
|
||||
#include <tinyxml2.h>
|
||||
#endif
|
||||
|
||||
static void AddFilesToList(const std::string& FileList, std::vector<std::string>& PathNames)
|
||||
|
@ -587,28 +587,28 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
|
||||
// Rule file
|
||||
else if (std::strncmp(argv[i], "--rule-file=", 12) == 0) {
|
||||
TiXmlDocument doc;
|
||||
if (doc.LoadFile(12+argv[i])) {
|
||||
TiXmlElement *node = doc.FirstChildElement();
|
||||
for (; node && node->ValueStr() == "rule"; node = node->NextSiblingElement()) {
|
||||
tinyxml2::XMLDocument doc;
|
||||
if (doc.LoadFile(12+argv[i]) == tinyxml2::XML_NO_ERROR) {
|
||||
tinyxml2::XMLElement *node = doc.FirstChildElement();
|
||||
for (; node && strcmp(node->Value(), "rule") == 0; node = node->NextSiblingElement()) {
|
||||
Settings::Rule rule;
|
||||
|
||||
TiXmlElement *pattern = node->FirstChildElement("pattern");
|
||||
tinyxml2::XMLElement *pattern = node->FirstChildElement("pattern");
|
||||
if (pattern) {
|
||||
rule.pattern = pattern->GetText();
|
||||
}
|
||||
|
||||
TiXmlElement *message = node->FirstChildElement("message");
|
||||
tinyxml2::XMLElement *message = node->FirstChildElement("message");
|
||||
if (message) {
|
||||
TiXmlElement *severity = message->FirstChildElement("severity");
|
||||
tinyxml2::XMLElement *severity = message->FirstChildElement("severity");
|
||||
if (severity)
|
||||
rule.severity = severity->GetText();
|
||||
|
||||
TiXmlElement *id = message->FirstChildElement("id");
|
||||
tinyxml2::XMLElement *id = message->FirstChildElement("id");
|
||||
if (id)
|
||||
rule.id = id->GetText();
|
||||
|
||||
TiXmlElement *summary = message->FirstChildElement("summary");
|
||||
tinyxml2::XMLElement *summary = message->FirstChildElement("summary");
|
||||
if (summary)
|
||||
rule.summary = summary->GetText();
|
||||
}
|
||||
|
|
|
@ -1,299 +0,0 @@
|
|||
Changes in version 1.0.1:
|
||||
- Fixed comment tags which were outputing as '<?--' instead of
|
||||
the correct '<!--'.
|
||||
- Implemented the Next and Prev methods of the TiXmlAttribute class.
|
||||
- Renamed 'LastAttribtute' to 'LastAttribute'
|
||||
- Fixed bad pointer to 'isspace' that could occur while parsing text.
|
||||
- Errors finding beginning and end of tags no longer throw it into an
|
||||
infinite loop. (Hopefully.)
|
||||
|
||||
Changes in version 1.0.2
|
||||
- Minor documentation fixes.
|
||||
|
||||
Changes in version 1.0.3
|
||||
- After nodes are added to a document, they return a pointer
|
||||
to the new node instead of a bool for success.
|
||||
- Elements can be constructed with a value, which is the
|
||||
element name. Every element must have a value or it will be
|
||||
invalid, but the code changes to enforce this are not fully
|
||||
in place.
|
||||
|
||||
Changes in version 1.1.0
|
||||
- Added the TiXmlAttributeSet class to pull the attributes into
|
||||
a seperate container.
|
||||
- Moved the doubly liked list out of XmlBase. Now XmlBase only
|
||||
requires the Print() function and defines some utility functions.
|
||||
- Moved errors into a seperate file. (With the idea of internationalization
|
||||
to the other latin-1 languages.)
|
||||
- Added the "NodeType"
|
||||
- Fixed white space parsing in text to conform with the standard.
|
||||
Basically, all white space becomes just one space.
|
||||
- Added the TiXmlDeclaration class to read xml declarations.
|
||||
|
||||
Changes in version 1.2.0
|
||||
- Removed the factory. The factory was not really in the spirit
|
||||
of small and simple, confused the code, and was of limited value.
|
||||
- Added FirstChildElement and NextSiblingElement, because they
|
||||
are such common functions.
|
||||
- Re-wrote the example to test and demonstrate more functionality.
|
||||
|
||||
Changes in version 1.2.1
|
||||
- Fixed a bug where comments couldn't be inside elements.
|
||||
- Loading now clears out existing XML rather than appending.
|
||||
- Added the "Clear" method on a node to delete all its children.
|
||||
|
||||
Changes in version 1.2.2
|
||||
- Fixed TiXmlAttribute::Previous actually returning "next." Thanks
|
||||
to Rickard Troedsson for the bug fix.
|
||||
|
||||
Changes in version 1.2.3
|
||||
- Added the TIXML prefix to the error strings to resolve conflicts
|
||||
with #defines in OS headers. Thanks to Steve Lhomme.
|
||||
- Fixed a delete buf that should be a delete [] buf.
|
||||
Thanks to Ephi Sinowitz.
|
||||
|
||||
Changes in version 1.2.4
|
||||
- ReplaceChild() was almost guarenteed to fail. Should be fixed,
|
||||
thanks to Joe Smith. Joe also pointed out that the Print() functions
|
||||
should take stream references: I agree, and would like to overload
|
||||
the Print() method to take either format, but I don't want to do
|
||||
this in a dot release.
|
||||
- Some compilers seem to need an extra <ctype.h> include. Thanks
|
||||
to Steve Lhomme for that.
|
||||
|
||||
Changes in version 2.0.0 BETA
|
||||
- Made the ToXXX() casts safe if 'this' is null.
|
||||
When "LoadFile" is called with a filename, the value will correctly get set.
|
||||
Thanks to Brian Yoder.
|
||||
- Fixed bug where isalpha() and isalnum() would get called with a negative value for
|
||||
high ascii numbers. Thanks to Alesky Aksenov.
|
||||
- Fixed some errors codes that were not getting set.
|
||||
- Made methods "const" that were not.
|
||||
- Added a switch to enable or disable the ignoring of white space. ( TiXmlDocument::SetIgnoreWhiteSpace() )
|
||||
- Greater standardization and code re-use in the parser.
|
||||
- Added a stream out operator.
|
||||
- Added a stream in operator.
|
||||
- Entity support, of predefined entites. &#x entities are untouched by input or output.
|
||||
- Improved text out formatting.
|
||||
- Fixed ReplaceChild bug, thanks to Tao Chen.
|
||||
|
||||
Changes in version 2.0.1
|
||||
- Fixed hanging on loading a 0 length file. Thanks to Jeff Scozzafava.
|
||||
- Fixed crashing on InsertBeforeChild and InsertAfterChild. Also possibility of bad links being
|
||||
created by same function. Thanks to Frank De prins.
|
||||
- Added missing licence text. Thanks to Lars Willemsens.
|
||||
- Added <ctype.h> include, at the suggestion of Steve Walters.
|
||||
|
||||
Changes in version 2.1.0
|
||||
- Yves Berquin brings us the STL switch. The forum on SourceForge, and various emails to
|
||||
me, have long debated all out STL vs. no STL at all. And now you can have it both ways.
|
||||
TinyXml will compile either way.
|
||||
|
||||
Changes in version 2.1.1
|
||||
- Compilation warnings.
|
||||
|
||||
Changes in version 2.1.2
|
||||
- Uneeded code is not compiled in the STL case.
|
||||
- Changed headers so that STL can be turned on or off in tinyxml.h
|
||||
|
||||
Changes in version 2.1.3
|
||||
- Fixed non-const reference in API; now uses a pointer.
|
||||
- Copy constructor of TiXmlString not checking for assignment to self.
|
||||
- Nimrod Cohen found a truly evil bug in the STL implementation that occurs
|
||||
when a string is converted to a c_str and then assigned to self. Search for
|
||||
STL_STRING_BUG for a full description. I'm asserting this is a Microsoft STL
|
||||
bug, since &string and string.c_str() should never be the same. Nevertheless,
|
||||
the code works around it.
|
||||
- Urivan Saaib pointed out a compiler conflict, where the C headers define
|
||||
the isblank macro, which was wiping out the TiXmlString::isblank() method.
|
||||
The method was unused and has been removed.
|
||||
|
||||
Changes in version 2.1.4
|
||||
- Reworked the entity code. Entities were not correctly surving round trip input and output.
|
||||
Will now automatically create entities for high ascii in output.
|
||||
|
||||
Changes in version 2.1.5
|
||||
- Bug fix by kylotan : infinite loop on some input (tinyxmlparser.cpp rev 1.27)
|
||||
- Contributed by Ivica Aracic (bytelord) : 1 new VC++ project to compile versions as static libraries (tinyxml_lib.dsp),
|
||||
and an example usage in xmltest.dsp
|
||||
(Patch request ID 678605)
|
||||
- A suggestion by Ronald Fenner Jr (dormlock) to add #include <istream> and <ostream> for Apple's Project Builder
|
||||
(Patch request ID 697642)
|
||||
- A patch from ohommes that allows to parse correctly dots in element names and attribute names
|
||||
(Patch request 602600 and kylotan 701728)
|
||||
- A patch from hermitgeek ( James ) and wasteland for improper error reporting
|
||||
- Reviewed by Lee, with the following changes:
|
||||
- Got sick of fighting the STL/non-STL thing in the windows build. Broke
|
||||
them out as seperate projects.
|
||||
- I have too long not included the dsw. Added.
|
||||
- TinyXmlText had a protected Print. Odd.
|
||||
- Made LinkEndChild public, with docs and appropriate warnings.
|
||||
- Updated the docs.
|
||||
|
||||
2.2.0
|
||||
- Fixed an uninitialized pointer in the TiXmlAttributes
|
||||
- Fixed STL compilation problem in MinGW (and gcc 3?) - thanks Brian Yoder for finding this one
|
||||
- Fixed a syntax error in TiXmlDeclaration - thanks Brian Yoder
|
||||
- Fletcher Dunn proposed and submitted new error handling that tracked the row and column. Lee
|
||||
modified it to not have performance impact.
|
||||
- General cleanup suggestions from Fletcher Dunn.
|
||||
- In error handling, general errors will no longer clear the error state of specific ones.
|
||||
- Fix error in documentation : comments starting with "<?--" instead of "<!--" (thanks ion_pulse)
|
||||
- Added the TiXmlHandle. An easy, safe way to browse XML DOMs with less code.
|
||||
- Added QueryAttribute calls which have better error messaging. (Proposed by Fletcher Dunn)
|
||||
- Nodes and attributes can now print themselves to strings. (Yves suggestion)
|
||||
- Fixed bug where entities with one character would confuse parser. (Thanks Roman)
|
||||
|
||||
2.2.1
|
||||
- Additional testing (no more bugs found to be fixed in this release)
|
||||
- Significant performance improvement to the cursor code.
|
||||
|
||||
2.3.0
|
||||
- User Data are now defined in TiXmlBase instead of TiXmlNode
|
||||
- Character Entities are now UCS-2
|
||||
- Character Entities can be decimal or hexadecimal
|
||||
- UTF-8 conversion.
|
||||
- Fixed many, many bugs.
|
||||
|
||||
2.3.1
|
||||
- Fixed bug in handling nulls embedded in the input.
|
||||
- Make UTF-8 parser tolerant of bad text encoding.
|
||||
- Added encoding detection.
|
||||
- Many fixes and input from John-Philip Leonard Johansson (JP) and Ellers,
|
||||
including UTF-8 feedback, bug reports, and patches. Thanks!
|
||||
- Added version # constants - a suggestion from JP and Ellers.
|
||||
- [ 979180 ] Missing ; in entity reference, fix from Rob Laveaux.
|
||||
- Copy constructors and assignment have been a long time coming. Thanks to
|
||||
Fokke and JP.
|
||||
|
||||
2.3.2
|
||||
- Made the IsAlpha and IsAlphaNum much more tolerant of non-UTF-8 encodings. Thanks
|
||||
Volker Boerchers for finding the issue.
|
||||
- Ran the program though the magnificent Valgrind - http://valgrind.kde.org - to check
|
||||
for memory errors. Fixed some minor issues.
|
||||
|
||||
2.3.3
|
||||
- Fixed crash when test program was run from incorrect directory.
|
||||
- Fixed bug 1070717 - empty document not returned correctly - thanks Katsuhisa Yuasa.
|
||||
- Bug 1079301 resolved - deprecated stdlib calls. Thanks Adrian Boeing.
|
||||
- Bug 1035218 fixed - documentation errors. Xunji Luo
|
||||
- Other bug fixes have accumulated and been fixed on the way as well; my apologies to
|
||||
authors not credited!
|
||||
- Big fix / addition is to correctly return const values. TinyXml could basically
|
||||
remove const in a method like this: TiXmlElement* Foo() const, where the returned element
|
||||
was a pointer to internal data. That is now: const TiXmlElement* Foo() const and
|
||||
TiXmlElement* Foo().
|
||||
|
||||
2.3.4
|
||||
- Fixed additional const errors, thanks Kent Gibson.
|
||||
- Correctly re-enable warnings after tinyxml header. Thanks Cory Nelson.
|
||||
- Variety of type cleanup and warning fixes. Thanks Warren Stevens.
|
||||
- Cleaned up unneeded constructor calls in TinyString - thanks to Geoff Carlton and
|
||||
the discussion group on sourceforge.
|
||||
|
||||
2.4.0
|
||||
- Improved string class, thanks Tyge Lovset (whose name gets mangled in English - sorry)
|
||||
- Type cast compiler warning, thanks Rob van den Bogaard
|
||||
- Added GetText() convenience function. Thanks Ilya Parniuk & Andrew Ellers for input.
|
||||
- Many thanks to marlonism for finding an infinite loop in bad xml.
|
||||
- A patch to cleanup warnings from Robert Gebis.
|
||||
- Added ValueStr() to get the value of a node as a string.
|
||||
- TiXmlText can now parse and output as CDATA
|
||||
- Additional string improvement from James (z2895)
|
||||
- Removed extraneous 'const', thanks David Aldrich
|
||||
- First pass at switching to the "safe" stdlib functions. Many people have suggested and
|
||||
pushed on this, but Warren Stevens put together the first proposal.
|
||||
- TinyXml now will do EOL normalization before parsing, consistent with the W3C XML spec.
|
||||
- Documents loaded with the UTF-8 BOM will now save with the UTF-8 BOM. Good suggestion
|
||||
from 'instructor_'
|
||||
- Ellers submitted his very popular tutorials, which have been added to the distribution.
|
||||
|
||||
2.4.1
|
||||
- Fixed CDATA output formatting
|
||||
- Fixed memory allocators in TinyString to work with overloaded new/delete
|
||||
|
||||
2.4.2
|
||||
- solosnake pointed out that TIXML_LOG causes problems on an XBOX. The definition in the header
|
||||
was superflous and was moved inside of DEBUG_PARSING
|
||||
|
||||
2.4.3
|
||||
- Fixed a test bug that caused a crash in 'xmltest'. TinyXML was fine, but it isn't good
|
||||
to ship with a broken test suite.
|
||||
- Started converting some functions to not cast between std::string and const char*
|
||||
quite as often.
|
||||
- Added FILE* versions of the document loads - good suggestion from Wade Brainerd
|
||||
- Empty documents might not always return the errors they should. [1398915] Thanks to igor v.
|
||||
- Added some asserts for multiply adding a node, regardng bug [1391937] suggested by Paco Arjonilla.
|
||||
|
||||
2.4.4
|
||||
- Bug find thanks to andre-gross found a memory leak that occured when a document failed to load.
|
||||
- Bug find (and good analysis) by VirtualJim who found a case where attribute parsing
|
||||
should be throwing an error and wasn't.
|
||||
- Steve Hyatt suggested the QueryValueAttribute method, which is now implemented.
|
||||
- DavidA identified a chunk of dead code.
|
||||
- Andrew Baxter sent in some compiler warnings that were good clean up points.
|
||||
|
||||
2.5
|
||||
- Added the Visit() API. Many thanks to both Andrew Ellerton and John-Philip for all their
|
||||
work, code, suggestion, and just general pushing that it should be done.
|
||||
- Removed existing streaming code and use TiXmlPrinter instead.
|
||||
- [ tinyxml-Bugs-1527079 ] Compile error in tinystr.cpp fixed, thanks to Paul Suggs
|
||||
- [ tinyxml-Bugs-1522890 ] SaveFile has no error checks fixed, thanks to Ivan Dobrokotov
|
||||
- Ivan Dobrokotov also reported redundant memory allocation in the Attribute() method, which
|
||||
upon investigation was a mess. The attribute should now be fixed for both const char* and
|
||||
std::string, and the return types match the input parameters.
|
||||
- Feature [ 1511105 ] Make TiXmlComment constructor accept a string / char*, implemented.
|
||||
Thanks to Karl Itschen for the feedback.
|
||||
- [ 1480108 ] Stream parsing fails when CDATA contains tags was found by Tobias Grimm, who also
|
||||
submitted a test case and patch. A significant bug in CDATA streaming (operator>>) has now
|
||||
been fixed.
|
||||
|
||||
2.5.2
|
||||
- Lieven, and others, pointed out a missing const-cast that upset the Open Watcom compiler.
|
||||
Should now be fixed.
|
||||
- ErrorRow and ErrorCol should have been const, and weren't. Fixed thanks to Dmitry Polutov.
|
||||
|
||||
2.5.3
|
||||
- zloe_zlo identified a missing string specialization for QueryValueAttribute() [ 1695429 ]. Worked
|
||||
on this bug, but not sure how to fix it in a safe, cross-compiler way.
|
||||
- increased warning level to 4 and turned on detect 64 bit portability issues for VC2005.
|
||||
May address [ 1677737 ] VS2005: /Wp64 warnings
|
||||
- grosheck identified several problems with the Document copy. Many thanks for [ 1660367 ]
|
||||
- Nice catch, and suggested fix, be Gilad Novik on the Printer dropping entities.
|
||||
"[ 1600650 ] Bug when printing xml text" is now fixed.
|
||||
- A subtle fix from Nicos Gollan in the tinystring initializer:
|
||||
[ 1581449 ] Fix initialiser of TiXmlString::nullrep_
|
||||
- Great catch, although there isn't a submitter for the bug. [ 1475201 ] TinyXML parses entities in comments.
|
||||
Comments should not, in fact, parse entities. Fixed the code path and added tests.
|
||||
- We were not catching all the returns from ftell. Thanks to Bernard for catching that.
|
||||
|
||||
2.5.4
|
||||
- A TiXMLDocument can't be a sub-node. Block this from happening in the 'replace'. Thanks Noam.
|
||||
- [ 1714831 ] TiXmlBase::location is not copied by copy-ctors, fix reported and suggested by Nicola Civran.
|
||||
- Fixed possible memory overrun in the comment reading code - thanks gcarlton77
|
||||
|
||||
2.5.5
|
||||
- Alex van der Wal spotted incorrect types (lf) being used in print and scan. robertnestor pointed out some problems with the simple solution. Types updated.
|
||||
- Johannes Hillert pointed out some bug typos.
|
||||
- Christian Mueller identified inconsistent error handling with Attributes.
|
||||
- olivier barthelemy also reported a problem with double truncation, also related to the %lf issue.
|
||||
- zaelsius came up with a great (and simple) suggestion to fix QueryValueAttribute truncating strings.
|
||||
- added some null pointer checks suggested by hansenk
|
||||
- Sami Väisänen found a (rare) buffer overrun that could occur in parsing.
|
||||
- vi tri filed a bug that led to a refactoring of the attribute setting mess (as well as adding a missing SetDoubleAttribute() )
|
||||
- removed TIXML_ERROR_OUT_OF_MEMORY. TinyXML does not systematically address OOO, and the notion it does is misleading.
|
||||
- vanneto, keithmarshall, others all reported the warning from IsWhiteSpace() usage. Cleaned this up - many thanks to everyone who reported this one.
|
||||
- tibur found a bug in end tag parsing
|
||||
|
||||
|
||||
2.6.2
|
||||
- Switched over to VC 2010
|
||||
- Fixed up all the build issues arising from that. (Lots of latent build problems.)
|
||||
- Removed the old, now unmaintained and likely not working, build files.
|
||||
- Fixed some static analysis issues reported by orbitcowboy from cppcheck.
|
||||
- Bayard 95 sent in analysis from a different analyzer - fixes applied from that as well.
|
||||
- Tim Kosse sent a patch fixing an infinite loop.
|
||||
- Ma Anguo identified a doc issue.
|
||||
- Eddie Cohen identified a missing qualifier resulting in a compilation error on some systems.
|
||||
- Fixed a line ending bug. (What year is this? Can we all agree on a format for text files? Please? ...oh well.)
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
/*
|
||||
www.sourceforge.net/projects/tinyxml
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TIXML_USE_STL
|
||||
|
||||
#include "tinystr.h"
|
||||
|
||||
// Error value for find primitive
|
||||
const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1);
|
||||
|
||||
|
||||
// Null rep.
|
||||
TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } };
|
||||
|
||||
|
||||
void TiXmlString::reserve (size_type cap)
|
||||
{
|
||||
if (cap > capacity())
|
||||
{
|
||||
TiXmlString tmp;
|
||||
tmp.init(length(), cap);
|
||||
memcpy(tmp.start(), data(), length());
|
||||
swap(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TiXmlString& TiXmlString::assign(const char* str, size_type len)
|
||||
{
|
||||
size_type cap = capacity();
|
||||
if (len > cap || cap > 3*(len + 8))
|
||||
{
|
||||
TiXmlString tmp;
|
||||
tmp.init(len);
|
||||
memcpy(tmp.start(), str, len);
|
||||
swap(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
memmove(start(), str, len);
|
||||
set_size(len);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
TiXmlString& TiXmlString::append(const char* str, size_type len)
|
||||
{
|
||||
size_type newsize = length() + len;
|
||||
if (newsize > capacity())
|
||||
{
|
||||
reserve (newsize + capacity());
|
||||
}
|
||||
memmove(finish(), str, len);
|
||||
set_size(newsize);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
TiXmlString operator + (const TiXmlString & a, const TiXmlString & b)
|
||||
{
|
||||
TiXmlString tmp;
|
||||
tmp.reserve(a.length() + b.length());
|
||||
tmp += a;
|
||||
tmp += b;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
TiXmlString operator + (const TiXmlString & a, const char* b)
|
||||
{
|
||||
TiXmlString tmp;
|
||||
TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( strlen(b) );
|
||||
tmp.reserve(a.length() + b_len);
|
||||
tmp += a;
|
||||
tmp.append(b, b_len);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
TiXmlString operator + (const char* a, const TiXmlString & b)
|
||||
{
|
||||
TiXmlString tmp;
|
||||
TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) );
|
||||
tmp.reserve(a_len + b.length());
|
||||
tmp.append(a, a_len);
|
||||
tmp += b;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
#endif // TIXML_USE_STL
|
|
@ -1,305 +0,0 @@
|
|||
/*
|
||||
www.sourceforge.net/projects/tinyxml
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TIXML_USE_STL
|
||||
|
||||
#ifndef TIXML_STRING_INCLUDED
|
||||
#define TIXML_STRING_INCLUDED
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
/* The support for explicit isn't that universal, and it isn't really
|
||||
required - it is used to check that the TiXmlString class isn't incorrectly
|
||||
used. Be nice to old compilers and macro it here:
|
||||
*/
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200 )
|
||||
// Microsoft visual studio, version 6 and higher.
|
||||
#define TIXML_EXPLICIT explicit
|
||||
#elif defined(__GNUC__) && (__GNUC__ >= 3 )
|
||||
// GCC version 3 and higher.s
|
||||
#define TIXML_EXPLICIT explicit
|
||||
#else
|
||||
#define TIXML_EXPLICIT
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
TiXmlString is an emulation of a subset of the std::string template.
|
||||
Its purpose is to allow compiling TinyXML on compilers with no or poor STL support.
|
||||
Only the member functions relevant to the TinyXML project have been implemented.
|
||||
The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase
|
||||
a string and there's no more room, we allocate a buffer twice as big as we need.
|
||||
*/
|
||||
class TiXmlString
|
||||
{
|
||||
public :
|
||||
// The size type used
|
||||
typedef size_t size_type;
|
||||
|
||||
// Error value for find primitive
|
||||
static const size_type npos; // = -1;
|
||||
|
||||
|
||||
// TiXmlString empty constructor
|
||||
TiXmlString () : rep_(&nullrep_)
|
||||
{
|
||||
}
|
||||
|
||||
// TiXmlString copy constructor
|
||||
TiXmlString ( const TiXmlString & copy) : rep_(0)
|
||||
{
|
||||
init(copy.length());
|
||||
memcpy(start(), copy.data(), length());
|
||||
}
|
||||
|
||||
// TiXmlString constructor, based on a string
|
||||
TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0)
|
||||
{
|
||||
init( static_cast<size_type>( strlen(copy) ));
|
||||
memcpy(start(), copy, length());
|
||||
}
|
||||
|
||||
// TiXmlString constructor, based on a string
|
||||
TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0)
|
||||
{
|
||||
init(len);
|
||||
memcpy(start(), str, len);
|
||||
}
|
||||
|
||||
// TiXmlString destructor
|
||||
~TiXmlString ()
|
||||
{
|
||||
quit();
|
||||
}
|
||||
|
||||
TiXmlString& operator = (const char * copy)
|
||||
{
|
||||
return assign( copy, (size_type)strlen(copy));
|
||||
}
|
||||
|
||||
TiXmlString& operator = (const TiXmlString & copy)
|
||||
{
|
||||
return assign(copy.start(), copy.length());
|
||||
}
|
||||
|
||||
|
||||
// += operator. Maps to append
|
||||
TiXmlString& operator += (const char * suffix)
|
||||
{
|
||||
return append(suffix, static_cast<size_type>( strlen(suffix) ));
|
||||
}
|
||||
|
||||
// += operator. Maps to append
|
||||
TiXmlString& operator += (char single)
|
||||
{
|
||||
return append(&single, 1);
|
||||
}
|
||||
|
||||
// += operator. Maps to append
|
||||
TiXmlString& operator += (const TiXmlString & suffix)
|
||||
{
|
||||
return append(suffix.data(), suffix.length());
|
||||
}
|
||||
|
||||
|
||||
// Convert a TiXmlString into a null-terminated char *
|
||||
const char * c_str () const { return rep_->str; }
|
||||
|
||||
// Convert a TiXmlString into a char * (need not be null terminated).
|
||||
const char * data () const { return rep_->str; }
|
||||
|
||||
// Return the length of a TiXmlString
|
||||
size_type length () const { return rep_->size; }
|
||||
|
||||
// Alias for length()
|
||||
size_type size () const { return rep_->size; }
|
||||
|
||||
// Checks if a TiXmlString is empty
|
||||
bool empty () const { return rep_->size == 0; }
|
||||
|
||||
// Return capacity of string
|
||||
size_type capacity () const { return rep_->capacity; }
|
||||
|
||||
|
||||
// single char extraction
|
||||
const char& at (size_type index) const
|
||||
{
|
||||
assert( index < length() );
|
||||
return rep_->str[ index ];
|
||||
}
|
||||
|
||||
// [] operator
|
||||
char& operator [] (size_type index) const
|
||||
{
|
||||
assert( index < length() );
|
||||
return rep_->str[ index ];
|
||||
}
|
||||
|
||||
// find a char in a string. Return TiXmlString::npos if not found
|
||||
size_type find (char lookup) const
|
||||
{
|
||||
return find(lookup, 0);
|
||||
}
|
||||
|
||||
// find a char in a string from an offset. Return TiXmlString::npos if not found
|
||||
size_type find (char tofind, size_type offset) const
|
||||
{
|
||||
if (offset >= length()) return npos;
|
||||
|
||||
for (const char* p = c_str() + offset; *p != '\0'; ++p)
|
||||
{
|
||||
if (*p == tofind) return static_cast< size_type >( p - c_str() );
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
|
||||
void clear ()
|
||||
{
|
||||
//Lee:
|
||||
//The original was just too strange, though correct:
|
||||
// TiXmlString().swap(*this);
|
||||
//Instead use the quit & re-init:
|
||||
quit();
|
||||
init(0,0);
|
||||
}
|
||||
|
||||
/* Function to reserve a big amount of data when we know we'll need it. Be aware that this
|
||||
function DOES NOT clear the content of the TiXmlString if any exists.
|
||||
*/
|
||||
void reserve (size_type cap);
|
||||
|
||||
TiXmlString& assign (const char* str, size_type len);
|
||||
|
||||
TiXmlString& append (const char* str, size_type len);
|
||||
|
||||
void swap (TiXmlString& other)
|
||||
{
|
||||
Rep* r = rep_;
|
||||
rep_ = other.rep_;
|
||||
other.rep_ = r;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void init(size_type sz) { init(sz, sz); }
|
||||
void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; }
|
||||
char* start() const { return rep_->str; }
|
||||
char* finish() const { return rep_->str + rep_->size; }
|
||||
|
||||
struct Rep
|
||||
{
|
||||
size_type size, capacity;
|
||||
char str[1];
|
||||
};
|
||||
|
||||
void init(size_type sz, size_type cap)
|
||||
{
|
||||
if (cap)
|
||||
{
|
||||
// Lee: the original form:
|
||||
// rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap));
|
||||
// doesn't work in some cases of new being overloaded. Switching
|
||||
// to the normal allocation, although use an 'int' for systems
|
||||
// that are overly picky about structure alignment.
|
||||
const size_type bytesNeeded = sizeof(Rep) + cap;
|
||||
const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int );
|
||||
rep_ = reinterpret_cast<Rep*>( new int[ intsNeeded ] );
|
||||
|
||||
rep_->str[ rep_->size = sz ] = '\0';
|
||||
rep_->capacity = cap;
|
||||
}
|
||||
else
|
||||
{
|
||||
rep_ = &nullrep_;
|
||||
}
|
||||
}
|
||||
|
||||
void quit()
|
||||
{
|
||||
if (rep_ != &nullrep_)
|
||||
{
|
||||
// The rep_ is really an array of ints. (see the allocator, above).
|
||||
// Cast it back before delete, so the compiler won't incorrectly call destructors.
|
||||
delete [] ( reinterpret_cast<int*>( rep_ ) );
|
||||
}
|
||||
}
|
||||
|
||||
Rep * rep_;
|
||||
static Rep nullrep_;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
inline bool operator == (const TiXmlString & a, const TiXmlString & b)
|
||||
{
|
||||
return ( a.length() == b.length() ) // optimization on some platforms
|
||||
&& ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare
|
||||
}
|
||||
inline bool operator < (const TiXmlString & a, const TiXmlString & b)
|
||||
{
|
||||
return strcmp(a.c_str(), b.c_str()) < 0;
|
||||
}
|
||||
|
||||
inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); }
|
||||
inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; }
|
||||
inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); }
|
||||
inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); }
|
||||
|
||||
inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; }
|
||||
inline bool operator == (const char* a, const TiXmlString & b) { return b == a; }
|
||||
inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); }
|
||||
inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); }
|
||||
|
||||
TiXmlString operator + (const TiXmlString & a, const TiXmlString & b);
|
||||
TiXmlString operator + (const TiXmlString & a, const char* b);
|
||||
TiXmlString operator + (const char* a, const TiXmlString & b);
|
||||
|
||||
|
||||
/*
|
||||
TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString.
|
||||
Only the operators that we need for TinyXML have been developped.
|
||||
*/
|
||||
class TiXmlOutStream : public TiXmlString
|
||||
{
|
||||
public :
|
||||
|
||||
// TiXmlOutStream << operator.
|
||||
TiXmlOutStream & operator << (const TiXmlString & in)
|
||||
{
|
||||
*this += in;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// TiXmlOutStream << operator.
|
||||
TiXmlOutStream & operator << (const char * in)
|
||||
{
|
||||
*this += in;
|
||||
return *this;
|
||||
}
|
||||
|
||||
} ;
|
||||
|
||||
#endif // TIXML_STRING_INCLUDED
|
||||
#endif // TIXML_USE_STL
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,2 @@
|
|||
HEADERS += $${BASEPATH}tinystr.h \
|
||||
$${BASEPATH}tinyxml.h
|
||||
SOURCES += $${BASEPATH}tinystr.cpp \
|
||||
$${BASEPATH}tinyxml.cpp \
|
||||
$${BASEPATH}tinyxmlerror.cpp \
|
||||
$${BASEPATH}tinyxmlparser.cpp
|
||||
HEADERS += $${BASEPATH}tinyxml2.h
|
||||
SOURCES += $${BASEPATH}tinyxml2.cpp
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
www.sourceforge.net/projects/tinyxml
|
||||
Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
#include "tinyxml.h"
|
||||
|
||||
// The goal of the seperate error file is to make the first
|
||||
// step towards localization. tinyxml (currently) only supports
|
||||
// english error messages, but the could now be translated.
|
||||
//
|
||||
// It also cleans up the code a bit.
|
||||
//
|
||||
|
||||
const char* TiXmlBase::errorString[ TiXmlBase::TIXML_ERROR_STRING_COUNT ] =
|
||||
{
|
||||
"No error",
|
||||
"Error",
|
||||
"Failed to open file",
|
||||
"Error parsing Element.",
|
||||
"Failed to read Element name",
|
||||
"Error reading Element value.",
|
||||
"Error reading Attributes.",
|
||||
"Error: empty tag.",
|
||||
"Error reading end tag.",
|
||||
"Error parsing Unknown.",
|
||||
"Error parsing Comment.",
|
||||
"Error parsing Declaration.",
|
||||
"Error document empty.",
|
||||
"Error null (0) or unexpected EOF found in input stream.",
|
||||
"Error parsing CDATA.",
|
||||
"Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.",
|
||||
};
|
File diff suppressed because it is too large
Load Diff
|
@ -90,10 +90,10 @@ QStandardItem *ResultsTree::CreateLineNumberItem(const QString &linenumber)
|
|||
return item;
|
||||
}
|
||||
|
||||
void ResultsTree::AddErrorItem(const ErrorItem &item)
|
||||
bool ResultsTree::AddErrorItem(const ErrorItem &item)
|
||||
{
|
||||
if (item.files.isEmpty()) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
QString realfile = StripPath(item.files[0], false);
|
||||
|
@ -136,7 +136,7 @@ void ResultsTree::AddErrorItem(const ErrorItem &item)
|
|||
SeverityToIcon(line.severity));
|
||||
|
||||
if (!stditem)
|
||||
return;
|
||||
return false;
|
||||
|
||||
//Add user data to that item
|
||||
QMap<QString, QVariant> data;
|
||||
|
@ -178,6 +178,7 @@ void ResultsTree::AddErrorItem(const ErrorItem &item)
|
|||
if (!hide) {
|
||||
ShowFileItem(realfile);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent,
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
*
|
||||
* @param item Error item data
|
||||
*/
|
||||
void AddErrorItem(const ErrorItem &item);
|
||||
bool AddErrorItem(const ErrorItem &item);
|
||||
|
||||
/**
|
||||
* @brief Clear all errors from the tree
|
||||
|
|
|
@ -102,9 +102,10 @@ void ResultsView::Progress(int value, const QString& description)
|
|||
void ResultsView::Error(const ErrorItem &item)
|
||||
{
|
||||
mErrorsFound = true;
|
||||
mUI.mTree->AddErrorItem(item);
|
||||
emit GotResults();
|
||||
mStatistics->AddItem(ShowTypes::SeverityToShowType(item.severity));
|
||||
if (mUI.mTree->AddErrorItem(item)) {
|
||||
emit GotResults();
|
||||
mStatistics->AddItem(ShowTypes::SeverityToShowType(item.severity));
|
||||
}
|
||||
}
|
||||
|
||||
void ResultsView::ShowResults(ShowTypes::ShowType type, bool show)
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -3,5 +3,5 @@
|
|||
# npm install -g clean-css
|
||||
# npm install -g uglify-js
|
||||
|
||||
cat css/all.css css/demo.css css/normalize.css | cleancss -o css/pack.css
|
||||
uglifyjs js/github.js js/picnet.table.filter.min.js -o js/pack.js -c -m
|
||||
cat css/all.css css/demo.css css/normalize.css | cleancss --s0 -o css/pack.css
|
||||
uglifyjs js/github.js js/picnet.table.filter.min.js -o js/pack.js --compress --mangle
|
||||
|
|
|
@ -5,7 +5,7 @@ rem npm install -g uglify-js
|
|||
|
||||
pushd %~dp0
|
||||
|
||||
type css\all.css css\demo.css css\normalize.css | cleancss -o css\pack.css
|
||||
cmd /c uglifyjs js/github.js js/picnet.table.filter.min.js -o js/pack.js -c -m
|
||||
type css\all.css css\demo.css css\normalize.css | cleancss --s0 -o css\pack.css
|
||||
cmd /c uglifyjs js/github.js js/picnet.table.filter.min.js -o js/pack.js --compress --mangle
|
||||
|
||||
popd
|
||||
|
|
|
@ -178,7 +178,7 @@ void CheckBufferOverrun::bufferNotZeroTerminatedError(const Token *tok, const st
|
|||
|
||||
void CheckBufferOverrun::argumentSizeError(const Token *tok, const std::string &functionName, const std::string &varname)
|
||||
{
|
||||
reportError(tok, Severity::style, "argumentSize", "the array " + varname + " is too small, the function " + functionName + " expects a bigger array");
|
||||
reportError(tok, Severity::warning, "argumentSize", "The array '" + varname + "' is too small, the function '" + functionName + "' expects a bigger one.");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
|
@ -718,15 +718,24 @@ void CheckClass::suggestInitializationList(const Token* tok, const std::string&
|
|||
static bool checkFunctionUsage(const std::string& name, const Scope* scope)
|
||||
{
|
||||
if (!scope)
|
||||
return true; // Assume its used, if scope is not seen
|
||||
return true; // Assume it is used, if scope is not seen
|
||||
|
||||
for (std::list<Function>::const_iterator func = scope->functionList.begin(); func != scope->functionList.end(); ++func) {
|
||||
if (func->functionScope) {
|
||||
for (const Token *ftok = func->functionScope->classStart; ftok != func->functionScope->classEnd; ftok = ftok->next()) {
|
||||
if (ftok->str() == name && ftok->next()->str() == "(") // Function called. TODO: Handle overloads
|
||||
for (const Token *ftok = func->functionScope->classDef->linkAt(1); ftok != func->functionScope->classEnd; ftok = ftok->next()) {
|
||||
if (ftok->str() == name) // Function used. TODO: Handle overloads
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if ((func->type != Function::eCopyConstructor &&
|
||||
func->type != Function::eOperatorEqual) ||
|
||||
func->access != Private) // Assume it is used, if a function implementation isn't seen, but empty private copy constructors and assignment operators are OK
|
||||
return true;
|
||||
}
|
||||
|
||||
for (std::list<Scope*>::const_iterator i = scope->nestedList.begin(); i != scope->nestedList.end(); ++i) {
|
||||
if ((*i)->isClassOrStruct())
|
||||
if (checkFunctionUsage(name, *i)) // Check nested classes, which can access private functions of their base
|
||||
return true;
|
||||
}
|
||||
|
||||
return false; // Unused in this scope
|
||||
|
@ -745,31 +754,11 @@ void CheckClass::privateFunctions()
|
|||
if (Token::findsimplematch(scope->classStart, "; __property ;", scope->classEnd))
|
||||
continue;
|
||||
|
||||
// check that the whole class implementation is seen
|
||||
bool whole = true;
|
||||
for (std::list<Function>::const_iterator func = scope->functionList.begin(); func != scope->functionList.end(); ++func) {
|
||||
if (!func->hasBody) {
|
||||
// empty private copy constructors and assignment operators are OK
|
||||
if ((func->type == Function::eCopyConstructor ||
|
||||
func->type == Function::eOperatorEqual) &&
|
||||
func->access == Private)
|
||||
continue;
|
||||
|
||||
whole = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!whole)
|
||||
continue;
|
||||
|
||||
std::list<const Function*> FuncList;
|
||||
/** @todo embedded class have access to private functions */
|
||||
if (!scope->getNestedNonFunctions()) {
|
||||
for (std::list<Function>::const_iterator func = scope->functionList.begin(); func != scope->functionList.end(); ++func) {
|
||||
// Get private functions..
|
||||
if (func->type == Function::eFunction && func->access == Private)
|
||||
FuncList.push_back(&*func);
|
||||
}
|
||||
for (std::list<Function>::const_iterator func = scope->functionList.begin(); func != scope->functionList.end(); ++func) {
|
||||
// Get private functions..
|
||||
if (func->type == Function::eFunction && func->access == Private)
|
||||
FuncList.push_back(&*func);
|
||||
}
|
||||
|
||||
// Bailout for overridden virtual functions of base classes
|
||||
|
@ -791,23 +780,8 @@ void CheckClass::privateFunctions()
|
|||
for (std::list<Scope::FriendInfo>::const_iterator it = scope->friendList.begin(); !used && it != scope->friendList.end(); ++it)
|
||||
used = checkFunctionUsage(funcName, it->scope);
|
||||
|
||||
if (!used) {
|
||||
// Final check; check if the function pointer is used somewhere..
|
||||
const std::string _pattern("return|throw|(|)|,|= &|" + funcName);
|
||||
|
||||
// or if the function address is used somewhere...
|
||||
// eg. sigc::mem_fun(this, &className::classFunction)
|
||||
const std::string _pattern2("& " + scope->className + " :: " + funcName);
|
||||
const std::string methodAsArgument("(|, " + scope->className + " :: " + funcName + " ,|)");
|
||||
const std::string methodAssigned("%var% = &| " + scope->className + " :: " + funcName);
|
||||
|
||||
if (!Token::findmatch(_tokenizer->tokens(), _pattern.c_str()) &&
|
||||
!Token::findmatch(_tokenizer->tokens(), _pattern2.c_str()) &&
|
||||
!Token::findmatch(_tokenizer->tokens(), methodAsArgument.c_str()) &&
|
||||
!Token::findmatch(_tokenizer->tokens(), methodAssigned.c_str())) {
|
||||
unusedPrivateFunctionError(FuncList.front()->tokenDef, scope->className, funcName);
|
||||
}
|
||||
}
|
||||
if (!used)
|
||||
unusedPrivateFunctionError(FuncList.front()->tokenDef, scope->className, funcName);
|
||||
|
||||
FuncList.pop_front();
|
||||
}
|
||||
|
@ -823,6 +797,16 @@ void CheckClass::unusedPrivateFunctionError(const Token *tok, const std::string
|
|||
// ClassCheck: Check that memset is not used on classes
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
const Scope* findFunctionOf(const Scope* scope)
|
||||
{
|
||||
while (scope) {
|
||||
if (scope->type == Scope::eFunction)
|
||||
return scope->functionOf;
|
||||
scope = scope->nestedIn;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CheckClass::noMemset()
|
||||
{
|
||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||
|
@ -839,27 +823,30 @@ void CheckClass::noMemset()
|
|||
arg3 = arg3->nextArgument();
|
||||
|
||||
const Token *typeTok = 0;
|
||||
const Scope *type = 0;
|
||||
if (Token::Match(arg3, "sizeof ( %type% ) )"))
|
||||
typeTok = arg3->tokAt(2);
|
||||
else if (Token::Match(arg3, "sizeof ( %type% :: %type% ) )"))
|
||||
typeTok = arg3->tokAt(4);
|
||||
else if (Token::Match(arg3, "sizeof ( struct %type% ) )"))
|
||||
typeTok = arg3->tokAt(3);
|
||||
else if (Token::Match(arg1, "&| %var% ,")) {
|
||||
else if (Token::simpleMatch(arg3, "sizeof ( * this ) )") || Token::simpleMatch(arg1, "this ,")) {
|
||||
type = findFunctionOf(arg3->scope());
|
||||
} else if (Token::Match(arg1, "&| %var% ,")) {
|
||||
const Variable *var = arg1->str() == "&" ? arg1->next()->variable() : arg1->variable();
|
||||
if (var && (var->typeStartToken() == var->typeEndToken() || Token::Match(var->typeStartToken(), "%type% :: %type%"))
|
||||
&& (arg1->str() == "&" || var->isPointer() || var->isArray()))
|
||||
typeTok = var->typeEndToken();
|
||||
if (var && (arg1->str() == "&" || var->isPointer() || var->isArray()))
|
||||
type = var->type();
|
||||
}
|
||||
|
||||
// No type defined => The tokens didn't match
|
||||
if (!typeTok)
|
||||
if (!typeTok && !type)
|
||||
continue;
|
||||
|
||||
if (typeTok->str() == "(")
|
||||
if (typeTok && typeTok->str() == "(")
|
||||
typeTok = typeTok->next();
|
||||
|
||||
const Scope *type = symbolDatabase->findVariableType(&(*scope), typeTok);
|
||||
if (!type)
|
||||
type = symbolDatabase->findVariableType(&(*scope), typeTok);
|
||||
|
||||
if (type)
|
||||
checkMemsetType(&(*scope), tok, type);
|
||||
|
@ -1572,6 +1559,7 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, bool&
|
|||
if (tok1->str() == "this" && tok1->previous()->isAssignmentOp())
|
||||
return(false);
|
||||
|
||||
const Token* jumpBackToken = 0;
|
||||
const Token *lastVarTok = tok1;
|
||||
const Token *end = tok1;
|
||||
for (;;) {
|
||||
|
@ -1586,6 +1574,8 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, bool&
|
|||
if (var && Token::simpleMatch(var->typeStartToken(), "std :: map")) // operator[] changes a map
|
||||
return(false);
|
||||
}
|
||||
if (!jumpBackToken)
|
||||
jumpBackToken = end->next(); // Check inside the [] brackets
|
||||
end = end->linkAt(1);
|
||||
} else if (end->strAt(1) == ")")
|
||||
end = end->next();
|
||||
|
@ -1626,7 +1616,7 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, bool&
|
|||
if (start->strAt(-1) == "delete")
|
||||
return(false);
|
||||
|
||||
tok1 = end;
|
||||
tok1 = jumpBackToken?jumpBackToken:end; // Jump back to first [ to check inside, or jump to end of expression
|
||||
}
|
||||
|
||||
// streaming: <<
|
||||
|
|
|
@ -140,6 +140,13 @@ void CheckIO::checkFileUsage()
|
|||
i->second.lastOperation = Filepointer::UNKNOWN_OP;
|
||||
}
|
||||
}
|
||||
} else if (tok->str() == "return" || tok->str() == "continue" || tok->str() == "break") { // Reset upon return, continue or break
|
||||
for (std::map<unsigned int, Filepointer>::iterator i = filepointers.begin(); i != filepointers.end(); ++i) {
|
||||
i->second.mode_indent = 0;
|
||||
i->second.mode = UNKNOWN;
|
||||
i->second.op_indent = 0;
|
||||
i->second.lastOperation = Filepointer::UNKNOWN_OP;
|
||||
}
|
||||
} else if (tok->varId() && Token::Match(tok, "%var% =") && (tok->strAt(2) != "fopen" && tok->strAt(2) != "freopen" && tok->strAt(2) != "tmpfile")) {
|
||||
std::map<unsigned int, Filepointer>::iterator i = filepointers.find(tok->varId());
|
||||
if (i != filepointers.end()) {
|
||||
|
@ -187,7 +194,7 @@ void CheckIO::checkFileUsage()
|
|||
if (tok->str() == "ungetc" && fileTok)
|
||||
fileTok = fileTok->nextArgument();
|
||||
operation = Filepointer::UNIMPORTANT;
|
||||
} else if (!Token::Match(tok, "if|for|while|catch|return")) {
|
||||
} else if (!Token::Match(tok, "if|for|while|catch|switch")) {
|
||||
const Token* const end2 = tok->linkAt(1);
|
||||
for (const Token* tok2 = tok->tokAt(2); tok2 != end2; tok2 = tok2->next()) {
|
||||
if (tok2->varId() && filepointers.find(tok2->varId()) != filepointers.end()) {
|
||||
|
|
|
@ -706,11 +706,16 @@ void CheckOther::sizeofForPointerError(const Token *tok, const std::string &varn
|
|||
// Detect redundant assignments: x = 0; x = 4;
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static bool nonLocal(const Variable* var)
|
||||
{
|
||||
return !var || (!var->isLocal() && !var->isArgument()) || var->isStatic() || var->isReference();
|
||||
}
|
||||
|
||||
static void eraseNotLocalArg(std::map<unsigned int, const Token*>& container, const SymbolDatabase* symbolDatabase)
|
||||
{
|
||||
for (std::map<unsigned int, const Token*>::iterator i = container.begin(); i != container.end();) {
|
||||
const Variable* var = symbolDatabase->getVariableFromVarId(i->first);
|
||||
if (!var || (!var->isLocal() && !var->isArgument()) || var->isStatic()) {
|
||||
if (!var || nonLocal(var)) {
|
||||
container.erase(i++);
|
||||
if (i == container.end())
|
||||
break;
|
||||
|
@ -757,12 +762,18 @@ void CheckOther::checkRedundantAssignment()
|
|||
break;
|
||||
else if (tok2->varId() == tok->varId())
|
||||
error = false;
|
||||
else if (Token::Match(tok2, "%var% (") && nonLocal(tok->variable())) { // Called function might use the variable
|
||||
const Function* func = symbolDatabase->findFunction(tok2);
|
||||
const Variable* var = tok->variable();
|
||||
if (!var || var->isGlobal() || var->isReference() || ((!func || func->nestedIn) && tok2->strAt(-1) != ".")) // Global variable, or member function
|
||||
error = false;
|
||||
}
|
||||
}
|
||||
if (error) {
|
||||
if (scope->type == Scope::eSwitch && Token::findmatch(it->second, "default|case", tok))
|
||||
redundantAssignmentInSwitchError(it->second, tok, tok->str());
|
||||
else
|
||||
redundantAssignmentError(it->second, tok, tok->str());
|
||||
redundantAssignmentError(it->second, tok, tok->str(), nonLocal(it->second->variable())); // Inconclusive for non-local variables
|
||||
}
|
||||
it->second = tok;
|
||||
}
|
||||
|
@ -839,13 +850,18 @@ void CheckOther::redundantCopyInSwitchError(const Token *tok1, const Token* tok2
|
|||
"Buffer '" + var + "' is being written before its old content has been used. 'break;' missing?");
|
||||
}
|
||||
|
||||
void CheckOther::redundantAssignmentError(const Token *tok1, const Token* tok2, const std::string& var)
|
||||
void CheckOther::redundantAssignmentError(const Token *tok1, const Token* tok2, const std::string& var, bool inconclusive)
|
||||
{
|
||||
std::list<const Token*> callstack;
|
||||
callstack.push_back(tok1);
|
||||
callstack.push_back(tok2);
|
||||
reportError(callstack, Severity::performance, "redundantAssignment",
|
||||
"Variable '" + var + "' is reassigned a value before the old one has been used.");
|
||||
if (inconclusive)
|
||||
reportError(callstack, Severity::performance, "redundantAssignment",
|
||||
"Variable '" + var + "' is reassigned a value before the old one has been used if variable is no semaphore variable.\n"
|
||||
"Variable '" + var + "' is reassigned a value before the old one has been used. Make sure that this variable is not used like a semaphore in a threading environment before simplifying this code.", true);
|
||||
else
|
||||
reportError(callstack, Severity::performance, "redundantAssignment",
|
||||
"Variable '" + var + "' is reassigned a value before the old one has been used.");
|
||||
}
|
||||
|
||||
void CheckOther::redundantAssignmentInSwitchError(const Token *tok1, const Token* tok2, const std::string &var)
|
||||
|
|
|
@ -330,7 +330,7 @@ private:
|
|||
void zerodivError(const Token *tok);
|
||||
void mathfunctionCallError(const Token *tok, const unsigned int numParam = 1);
|
||||
void cctypefunctionCallError(const Token *tok, const std::string &functionName, const std::string &value);
|
||||
void redundantAssignmentError(const Token *tok1, const Token* tok2, const std::string& var);
|
||||
void redundantAssignmentError(const Token *tok1, const Token* tok2, const std::string& var, bool inconclusive);
|
||||
void redundantAssignmentInSwitchError(const Token *tok1, const Token *tok2, const std::string &var);
|
||||
void redundantCopyError(const Token *tok1, const Token* tok2, const std::string& var);
|
||||
void redundantCopyInSwitchError(const Token *tok1, const Token* tok2, const std::string &var);
|
||||
|
@ -402,7 +402,7 @@ private:
|
|||
//performance
|
||||
c.redundantCopyError(0, "varname");
|
||||
c.redundantCopyError(0, 0, "var");
|
||||
c.redundantAssignmentError(0, 0, "var");
|
||||
c.redundantAssignmentError(0, 0, "var", false);
|
||||
|
||||
// style/warning
|
||||
c.oppositeInnerConditionError(0);
|
||||
|
|
|
@ -951,8 +951,8 @@ void CheckStl::size()
|
|||
}
|
||||
|
||||
// check for comparison to one
|
||||
if ((tok->previous() && !tok->previous()->isArithmeticalOp() && Token::Match(end, ">=|< 1")) ||
|
||||
(end->next() && !end->next()->isArithmeticalOp() && Token::Match(tok->tokAt(-2), "1 <=|>"))) {
|
||||
if ((tok->previous() && !tok->previous()->isArithmeticalOp() && Token::Match(end, ">=|< 1") && !end->tokAt(2)->isArithmeticalOp()) ||
|
||||
(end->next() && !end->next()->isArithmeticalOp() && Token::Match(tok->tokAt(-2), "1 <=|>") && !tok->tokAt(-3)->isArithmeticalOp())) {
|
||||
if (isContainerSizeSlow(tok1))
|
||||
sizeError(tok1);
|
||||
}
|
||||
|
|
|
@ -1059,7 +1059,8 @@ void CheckUninitVar::check()
|
|||
void CheckUninitVar::checkScope(const Scope* scope)
|
||||
{
|
||||
for (std::list<Variable>::const_iterator i = scope->varlist.begin(); i != scope->varlist.end(); ++i) {
|
||||
if ((_tokenizer->isCPP() && i->type() && !i->isPointer()) || i->isStatic() || i->isExtern() || i->isConst() || i->isArray() || i->isReference())
|
||||
if ((_tokenizer->isCPP() && i->type() && !i->isPointer() && i->type()->needInitialization != Scope::True) ||
|
||||
i->isStatic() || i->isExtern() || i->isConst() || i->isArray() || i->isReference())
|
||||
continue;
|
||||
if (i->nameToken()->strAt(1) == "(")
|
||||
continue;
|
||||
|
|
|
@ -410,10 +410,6 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
if (end->next()->str() == "const")
|
||||
function.isConst = true;
|
||||
|
||||
// pure virtual function
|
||||
if (Token::Match(end, ") const| = %any%"))
|
||||
function.isPure = true;
|
||||
|
||||
// count the number of constructors
|
||||
if (function.type == Function::eConstructor ||
|
||||
function.type == Function::eCopyConstructor)
|
||||
|
@ -424,10 +420,35 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
function.arg = function.argDef;
|
||||
|
||||
// out of line function
|
||||
if (Token::Match(end, ") const| ;") ||
|
||||
Token::Match(end, ") const| = %any%")) {
|
||||
if (Token::Match(end, ") const| ;")) {
|
||||
// find the function implementation later
|
||||
tok = end->next();
|
||||
if (tok->str() != ";")
|
||||
tok = tok->next();
|
||||
|
||||
scope->functionList.push_back(function);
|
||||
}
|
||||
|
||||
// default or delete
|
||||
else if (Token::Match(end, ") = default|delete ;")) {
|
||||
if (end->strAt(2) == "default")
|
||||
function.isDefault = true;
|
||||
else
|
||||
function.isDelete = true;
|
||||
|
||||
tok = end->tokAt(3);
|
||||
|
||||
scope->functionList.push_back(function);
|
||||
}
|
||||
|
||||
// pure virtual function
|
||||
else if (Token::Match(end, ") const| = %any% ;")) {
|
||||
function.isPure = true;
|
||||
|
||||
if (end->next()->str() == "const")
|
||||
tok = end->tokAt(4);
|
||||
else
|
||||
tok = end->tokAt(3);
|
||||
|
||||
scope->functionList.push_back(function);
|
||||
}
|
||||
|
@ -981,7 +1002,8 @@ bool SymbolDatabase::isFunction(const Token *tok, const Scope* outerScope, const
|
|||
tok->strAt(-1) == "::" || tok->strAt(-1) == "~" || // or a scope qualifier in front of tok
|
||||
outerScope->isClassOrStruct()) && // or a ctor/dtor
|
||||
(Token::Match(tok->next()->link(), ") const| ;|{|=") ||
|
||||
Token::Match(tok->next()->link(), ") : ::| %var% (|::|<|{"))) {
|
||||
Token::Match(tok->next()->link(), ") : ::| %var% (|::|<|{") ||
|
||||
Token::Match(tok->next()->link(), ") = delete|default ;"))) {
|
||||
*funcStart = tok;
|
||||
*argStart = tok->next();
|
||||
return true;
|
||||
|
@ -1642,6 +1664,8 @@ void SymbolDatabase::printOut(const char *title) const
|
|||
std::cout << " isStatic: " << (func->isStatic ? "true" : "false") << std::endl;
|
||||
std::cout << " isFriend: " << (func->isFriend ? "true" : "false") << std::endl;
|
||||
std::cout << " isExplicit: " << (func->isExplicit ? "true" : "false") << std::endl;
|
||||
std::cout << " isDefault: " << (func->isDefault ? "true" : "false") << std::endl;
|
||||
std::cout << " isDelete: " << (func->isDelete ? "true" : "false") << std::endl;
|
||||
std::cout << " isOperator: " << (func->isOperator ? "true" : "false") << std::endl;
|
||||
std::cout << " retFuncPtr: " << (func->retFuncPtr ? "true" : "false") << std::endl;
|
||||
std::cout << " tokenDef: " << _tokenizer->list.fileLine(func->tokenDef) << std::endl;
|
||||
|
@ -1882,7 +1906,7 @@ bool Function::isImplicitlyVirtual(bool defaultVal) const
|
|||
return true;
|
||||
else if (access == Private || access == Public || access == Protected) {
|
||||
bool safe = true;
|
||||
bool hasVirt = isImplicitlyVirtual_rec(functionScope->functionOf, safe);
|
||||
bool hasVirt = isImplicitlyVirtual_rec(nestedIn, safe);
|
||||
if (hasVirt)
|
||||
return true;
|
||||
else if (safe)
|
||||
|
|
|
@ -390,6 +390,8 @@ public:
|
|||
isStatic(false),
|
||||
isFriend(false),
|
||||
isExplicit(false),
|
||||
isDefault(false),
|
||||
isDelete(false),
|
||||
isOperator(false),
|
||||
retFuncPtr(false) {
|
||||
}
|
||||
|
@ -427,6 +429,8 @@ public:
|
|||
bool isStatic; // is static
|
||||
bool isFriend; // is friend
|
||||
bool isExplicit; // is explicit
|
||||
bool isDefault; // is default
|
||||
bool isDelete; // is delete
|
||||
bool isOperator; // is operator
|
||||
bool retFuncPtr; // returns function pointer
|
||||
|
||||
|
|
|
@ -793,7 +793,8 @@ bool TemplateSimplifier::simplifyCalculations(Token *_tokens)
|
|||
// keep parentheses here: operator new [] (size_t);
|
||||
// keep parentheses here: Functor()(a ... )
|
||||
// keep parentheses here: ) ( var ) ;
|
||||
if (Token::Match(tok->next(), "( %var% ) ;|)|,|]|%op%") &&
|
||||
if ((Token::Match(tok->next(), "( %var% ) ;|)|,|]") ||
|
||||
(Token::Match(tok->next(), "( %var% ) %op%") && (tok->tokAt(2)->varId()>0 || !Token::Match(tok->tokAt(4), "[*&]")))) &&
|
||||
!tok->isName() &&
|
||||
tok->str() != ">" &&
|
||||
tok->str() != "]" &&
|
||||
|
|
|
@ -1745,8 +1745,6 @@ bool Tokenizer::tokenize(std::istream &code,
|
|||
return false;
|
||||
}
|
||||
|
||||
simplifyDefaultAndDeleteInsideClass();
|
||||
|
||||
// Remove __declspec()
|
||||
simplifyDeclspec();
|
||||
|
||||
|
@ -2196,47 +2194,6 @@ bool Tokenizer::hasComplicatedSyntaxErrorsInTemplates()
|
|||
return false;
|
||||
}
|
||||
|
||||
void Tokenizer::simplifyDefaultAndDeleteInsideClass()
|
||||
{
|
||||
if (isC())
|
||||
return;
|
||||
|
||||
// Remove "= default|delete" inside class|struct definitions
|
||||
// Todo: Remove it if it is used "externally" too.
|
||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "struct|class %var% :|{")) {
|
||||
for (Token *tok2 = tok->tokAt(3); tok2; tok2 = tok2->next()) {
|
||||
if (tok2->str() == "{")
|
||||
tok2 = tok2->link();
|
||||
else if (tok2->str() == "}")
|
||||
break;
|
||||
else if (Token::Match(tok2, ") = delete|default ;")) {
|
||||
Token * const end = tok2->tokAt(4);
|
||||
tok2 = tok2->link()->previous();
|
||||
|
||||
// operator ==|>|<|..
|
||||
if (Token::Match(tok2->previous(), "operator %any%"))
|
||||
tok2 = tok2->previous();
|
||||
else if (Token::simpleMatch(tok2->tokAt(-2), "operator [ ]"))
|
||||
tok2 = tok2->tokAt(-2);
|
||||
else if (Token::simpleMatch(tok2->tokAt(-2), "operator ( )"))
|
||||
tok2 = tok2->tokAt(-2);
|
||||
else if (Token::simpleMatch(tok2->tokAt(-3), "operator delete [ ]"))
|
||||
tok2 = tok2->tokAt(-3);
|
||||
|
||||
while ((tok2->isName() && tok2->str().find(":") == std::string::npos) ||
|
||||
Token::Match(tok2, "[&*~]"))
|
||||
tok2 = tok2->previous();
|
||||
if (Token::Match(tok2, "[;{}]") || tok2->isName())
|
||||
Token::eraseTokens(tok2, end);
|
||||
else
|
||||
tok2 = end->previous();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Tokenizer::hasEnumsWithTypedef()
|
||||
{
|
||||
for (const Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
|
@ -6707,14 +6664,15 @@ bool Tokenizer::simplifyRedundantParentheses()
|
|||
ret = true;
|
||||
}
|
||||
|
||||
if (Token::Match(tok->previous(), "[(!*;{}] ( %var% )") && tok->next()->varId() != 0) {
|
||||
if (Token::Match(tok->previous(), "[(!*;{}] ( %var% )") &&
|
||||
(tok->next()->varId() != 0 || Token::Match(tok->tokAt(3), "[+-/=]"))) {
|
||||
// We have "( var )", remove the parentheses
|
||||
tok->deleteThis();
|
||||
tok->deleteNext();
|
||||
ret = true;
|
||||
}
|
||||
|
||||
while (Token::Match(tok->previous(), ";|{|}|[|]|(|)|.|,|! ( %var% .")) {
|
||||
while (Token::Match(tok->previous(), "[;{}[]().,!*] ( %var% .")) {
|
||||
Token *tok2 = tok->tokAt(2);
|
||||
while (Token::Match(tok2, ". %var%")) {
|
||||
tok2 = tok2->tokAt(2);
|
||||
|
@ -8513,7 +8471,7 @@ void Tokenizer::simplifyStructDecl()
|
|||
tok = tok->next()->link();
|
||||
|
||||
// unnamed anonymous struct/union so possibly remove it
|
||||
if (tok->next() && tok->next()->str() == ";") {
|
||||
if (tok && tok->next() && tok->next()->str() == ";") {
|
||||
if (tok1->str() == "union" && inFunction) {
|
||||
// Try to create references in the union..
|
||||
Token *tok2 = tok1->tokAt(2);
|
||||
|
|
|
@ -2701,21 +2701,21 @@ private:
|
|||
" char a[2];\n"
|
||||
" f(a);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (style) the array a is too small, the function f expects a bigger array\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:4]: (warning) The array 'a' is too small, the function 'f' expects a bigger one.\n", errout.str());
|
||||
|
||||
check("void f(float a[10][20]);\n"
|
||||
"void g() {\n"
|
||||
" float a[2][3];\n"
|
||||
" f(a);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (style) the array a is too small, the function f expects a bigger array\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:4]: (warning) The array 'a' is too small, the function 'f' expects a bigger one.\n", errout.str());
|
||||
|
||||
check("void f(char a[20]);\n"
|
||||
"void g() {\n"
|
||||
" int a[2];\n"
|
||||
" f(a);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (style) the array a is too small, the function f expects a bigger array\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:4]: (warning) The array 'a' is too small, the function 'f' expects a bigger one.\n", errout.str());
|
||||
|
||||
check("void f(char a[20]);\n"
|
||||
"void g() {\n"
|
||||
|
|
|
@ -163,6 +163,7 @@ private:
|
|||
TEST_CASE(constIfCfg); // ticket #1881 - fp when there are #if
|
||||
TEST_CASE(constFriend); // ticket #1921 - fp for friend function
|
||||
TEST_CASE(constUnion); // ticket #2111 - fp when there is a union
|
||||
TEST_CASE(constArrayOperator); // #4406
|
||||
|
||||
TEST_CASE(initializerListOrder);
|
||||
TEST_CASE(initializerListUsage);
|
||||
|
@ -2013,6 +2014,15 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:8]: (error) Using 'memset' on class that contains a 'std::string'.\n", errout.str());
|
||||
|
||||
checkNoMemset("class Fred {\n"
|
||||
" std::string b;\n"
|
||||
" void f();\n"
|
||||
"};\n"
|
||||
"void Fred::f() {\n"
|
||||
" memset(this, 0, sizeof(*this));\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (error) Using 'memset' on class that contains a 'std::string'.\n", errout.str());
|
||||
|
||||
checkNoMemset("class Fred\n"
|
||||
"{\n"
|
||||
"};\n"
|
||||
|
@ -5336,6 +5346,23 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void constArrayOperator() {
|
||||
checkConst("struct foo {\n"
|
||||
" int x;\n"
|
||||
" int y[5][724];\n"
|
||||
" T a() {\n"
|
||||
" return y[x++][6];\n"
|
||||
" }\n"
|
||||
" T b() {\n"
|
||||
" return y[1][++x];\n"
|
||||
" }\n"
|
||||
" T c() {\n"
|
||||
" return y[1][6];\n"
|
||||
" }\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("[test.cpp:10]: (style, inconclusive) Technically the member function 'foo::c' can be const.\n", errout.str());
|
||||
}
|
||||
|
||||
void checkInitializerListOrder(const char code[]) {
|
||||
// Clear the error log
|
||||
errout.str("");
|
||||
|
|
|
@ -62,6 +62,7 @@ private:
|
|||
TEST_CASE(simple7); // ticket #4531
|
||||
TEST_CASE(simple8);
|
||||
TEST_CASE(simple9); // ticket #4574
|
||||
TEST_CASE(simple10); // ticket #4388
|
||||
|
||||
TEST_CASE(initvar_with_this); // BUG 2190300
|
||||
TEST_CASE(initvar_if); // BUG 2190290
|
||||
|
@ -331,6 +332,16 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simple10() { // ticket #4388
|
||||
check("class Fred {\n"
|
||||
"public:\n"
|
||||
" Fred() = default;\n"
|
||||
"private:\n"
|
||||
" int x;\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void initvar_with_this() {
|
||||
check("struct Fred\n"
|
||||
"{\n"
|
||||
|
|
|
@ -324,6 +324,19 @@ private:
|
|||
" fprintf(fp, \"Here's the output.\\n\");\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:11]: (error) Used file that is not opened.\n", errout.str());
|
||||
|
||||
// #4466
|
||||
check("void chdcd_parse_nero(FILE *infile) {\n"
|
||||
" switch (mode) {\n"
|
||||
" case 0x0300:\n"
|
||||
" fclose(infile);\n"
|
||||
" return;\n"
|
||||
" case 0x0500:\n"
|
||||
" fclose(infile);\n"
|
||||
" return;\n"
|
||||
" }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void fileIOwithoutPositioning() {
|
||||
|
|
|
@ -6798,7 +6798,7 @@ private:
|
|||
" i = 1;\n"
|
||||
" i = 1;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (performance) Variable 'i' is reassigned a value before the old one has been used.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (performance, inconclusive) Variable 'i' is reassigned a value before the old one has been used if variable is no semaphore variable.\n", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" int i;\n"
|
||||
|
@ -6812,7 +6812,7 @@ private:
|
|||
" i = 1;\n"
|
||||
" i = 1;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (performance) Variable 'i' is reassigned a value before the old one has been used.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (performance, inconclusive) Variable 'i' is reassigned a value before the old one has been used if variable is no semaphore variable.\n", errout.str());
|
||||
|
||||
// Testing different types
|
||||
check("void f() {\n"
|
||||
|
@ -6820,12 +6820,21 @@ private:
|
|||
" bar = x;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" Foo& bar = foo();\n"
|
||||
" bar = x;\n"
|
||||
" bar = y;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (performance, inconclusive) Variable 'bar' is reassigned a value before the old one has been used if variable is no semaphore variable.\n", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" Foo& bar = foo();\n" // #4425. bar might refer to something global, etc.
|
||||
" bar = y();\n"
|
||||
" foo();\n"
|
||||
" bar = y();\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (performance) Variable 'bar' is reassigned a value before the old one has been used.\n", errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// Tests with function call between assignment
|
||||
check("void f(int i) {\n"
|
||||
|
@ -6882,6 +6891,57 @@ private:
|
|||
" i = 2;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:5]: (performance) Variable 'i' is reassigned a value before the old one has been used.\n", errout.str());
|
||||
|
||||
// #4513
|
||||
check("int x;\n"
|
||||
"int g() {\n"
|
||||
" return x*x;\n"
|
||||
"}\n"
|
||||
"void f() {\n"
|
||||
" x = 2;\n"
|
||||
" x = g();\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("int g() {\n"
|
||||
" return x*x;\n"
|
||||
"}\n"
|
||||
"void f(int x) {\n"
|
||||
" x = 2;\n"
|
||||
" x = g();\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:6]: (performance) Variable 'x' is reassigned a value before the old one has been used.\n", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" Foo& bar = foo();\n"
|
||||
" bar = x;\n"
|
||||
" bar = y();\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("class C {\n"
|
||||
" int x;\n"
|
||||
" void g() { return x*x; }\n"
|
||||
" void f();\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"void C::f() {\n"
|
||||
" x = 2;\n"
|
||||
" x = g();\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("class C {\n"
|
||||
" int x;\n"
|
||||
" void g() { return x*x; }\n"
|
||||
" void f();\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"void C::f(Foo z) {\n"
|
||||
" x = 2;\n"
|
||||
" x = z.g();\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:9]: (performance, inconclusive) Variable 'x' is reassigned a value before the old one has been used if variable is no semaphore variable.\n", errout.str());
|
||||
}
|
||||
|
||||
void redundantMemWrite() {
|
||||
|
|
|
@ -29,10 +29,6 @@
|
|||
<ClCompile Include="..\cli\filelister.cpp" />
|
||||
<ClCompile Include="..\cli\pathmatch.cpp" />
|
||||
<ClCompile Include="..\cli\threadexecutor.cpp" />
|
||||
<ClCompile Include="..\externals\tinyxml\tinystr.cpp" />
|
||||
<ClCompile Include="..\externals\tinyxml\tinyxml.cpp" />
|
||||
<ClCompile Include="..\externals\tinyxml\tinyxmlerror.cpp" />
|
||||
<ClCompile Include="..\externals\tinyxml\tinyxmlparser.cpp" />
|
||||
<ClCompile Include="options.cpp" />
|
||||
<ClCompile Include="test64bit.cpp" />
|
||||
<ClCompile Include="testassignif.cpp" />
|
||||
|
@ -83,8 +79,6 @@
|
|||
<ClInclude Include="..\cli\filelister.h" />
|
||||
<ClInclude Include="..\cli\pathmatch.h" />
|
||||
<ClInclude Include="..\cli\threadexecutor.h" />
|
||||
<ClInclude Include="..\externals\tinyxml\tinystr.h" />
|
||||
<ClInclude Include="..\externals\tinyxml\tinyxml.h" />
|
||||
<ClInclude Include="..\lib\config.h" />
|
||||
<ClInclude Include="options.h" />
|
||||
<ClInclude Include="redirect.h" />
|
||||
|
|
|
@ -148,18 +148,6 @@
|
|||
<ClCompile Include="..\cli\cmdlineparser.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\externals\tinyxml\tinystr.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\externals\tinyxml\tinyxml.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\externals\tinyxml\tinyxmlerror.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\externals\tinyxml\tinyxmlparser.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="testio.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -204,12 +192,6 @@
|
|||
<ClInclude Include="..\cli\cmdlineparser.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\externals\tinyxml\tinystr.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\externals\tinyxml\tinyxml.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\config.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -1572,6 +1572,18 @@ private:
|
|||
" fun(width % x.size() != 0);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #4584
|
||||
check("void f() {\n"
|
||||
" std::list<int> x;\n"
|
||||
" if (foo + 1 > x.size()) {}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
check("void f() {\n"
|
||||
" std::list<int> x;\n"
|
||||
" if (x.size() < 1 + foo) {}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void redundantCondition1() {
|
||||
|
|
|
@ -314,6 +314,7 @@ private:
|
|||
TEST_CASE(removeParentheses13);
|
||||
TEST_CASE(removeParentheses14); // Ticket #3309
|
||||
TEST_CASE(removeParentheses15); // Ticket #4142
|
||||
TEST_CASE(removeParentheses16); // Ticket #4423 '*(x.y)='
|
||||
|
||||
TEST_CASE(tokenize_double);
|
||||
TEST_CASE(tokenize_strings);
|
||||
|
@ -398,7 +399,6 @@ private:
|
|||
TEST_CASE(cpp0xtemplate1);
|
||||
TEST_CASE(cpp0xtemplate2);
|
||||
TEST_CASE(cpp0xtemplate3);
|
||||
TEST_CASE(cpp0xdefault);
|
||||
|
||||
TEST_CASE(arraySize);
|
||||
|
||||
|
@ -933,7 +933,9 @@ private:
|
|||
}
|
||||
|
||||
void removeCast9() {
|
||||
ASSERT_EQUALS("f ( ( double ) v1 * v2 )", tokenizeAndStringify("f((double)(v1)*v2)", true));
|
||||
ASSERT_EQUALS("f ( ( double ) ( v1 ) * v2 )", tokenizeAndStringify("f((double)(v1)*v2)", true));
|
||||
ASSERT_EQUALS("int v1 ; f ( ( double ) v1 * v2 )", tokenizeAndStringify("int v1; f((double)(v1)*v2)", true));
|
||||
ASSERT_EQUALS("f ( ( A ) ( B ) & x )", tokenizeAndStringify("f((A)(B)&x)", true)); // #4439
|
||||
}
|
||||
|
||||
void removeCast10() {
|
||||
|
@ -5007,6 +5009,12 @@ private:
|
|||
ASSERT_EQUALS("a = b ? c : ( d = 1 , 0 ) ;", tokenizeAndStringify("a = b ? c : (d=1,0);", false));
|
||||
}
|
||||
|
||||
void removeParentheses16() { // *(x.y)=
|
||||
// #4423
|
||||
ASSERT_EQUALS("* x = 0 ;", tokenizeAndStringify("*(x)=0;", false));
|
||||
ASSERT_EQUALS("* x . y = 0 ;", tokenizeAndStringify("*(x.y)=0;", false));
|
||||
}
|
||||
|
||||
void tokenize_double() {
|
||||
const char code[] = "void f()\n"
|
||||
"{\n"
|
||||
|
@ -6314,48 +6322,6 @@ private:
|
|||
tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void cpp0xdefault() {
|
||||
{
|
||||
const char *code = "struct foo {"
|
||||
" foo() = default;"
|
||||
"}";
|
||||
ASSERT_EQUALS("struct foo { }", tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
{
|
||||
const char *code = "struct A {"
|
||||
" void operator delete (void *) = delete;"
|
||||
" void operator delete[] (void *) = delete;"
|
||||
"}";
|
||||
ASSERT_EQUALS("struct A { }", tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
{
|
||||
const char *code = "struct A {"
|
||||
" void operator = (void *) = delete;"
|
||||
"}";
|
||||
ASSERT_EQUALS("struct A { }", tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
{
|
||||
const char *code = "struct foo {"
|
||||
" foo();"
|
||||
"}"
|
||||
"foo::foo() = delete;";
|
||||
TODO_ASSERT_EQUALS("struct foo { }",
|
||||
"struct foo { foo ( ) ; } foo :: foo ( ) = delete ;", tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
//ticket #3448 (segmentation fault)
|
||||
{
|
||||
const char *code = "struct A {"
|
||||
" void bar () = delete;"
|
||||
"};"
|
||||
"void baz () = delete;";
|
||||
ASSERT_EQUALS("struct A { } ; void baz ( ) = delete ;", tokenizeAndStringify(code));
|
||||
}
|
||||
}
|
||||
|
||||
std::string arraySize_(const std::string &code) {
|
||||
errout.str("");
|
||||
Settings settings;
|
||||
|
|
|
@ -2568,34 +2568,41 @@ private:
|
|||
}
|
||||
|
||||
void uninitvar2_structmembers() { // struct members
|
||||
checkUninitVar2("struct AB { int a; int b; };\n"
|
||||
"void f(void) {\n"
|
||||
" struct AB ab;\n"
|
||||
" int a = ab.a;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized struct member: ab.a\n", errout.str());
|
||||
|
||||
checkUninitVar2("struct AB { int a; int b; };\n"
|
||||
"void do_something(const struct AB ab);\n"
|
||||
"void f(void) {\n"
|
||||
" struct AB ab;\n"
|
||||
" ab.a = 0;\n"
|
||||
" do_something(ab);\n"
|
||||
"}\n", "test.c", true);
|
||||
"}\n", "test.c");
|
||||
ASSERT_EQUALS("[test.c:6]: (error) Uninitialized struct member: ab.b\n", errout.str());
|
||||
|
||||
checkUninitVar2("struct AB { int a; int b; };\n"
|
||||
"void f(void) {\n"
|
||||
" struct AB ab;\n"
|
||||
" int a = ab.a;\n"
|
||||
"}\n", "test.c", true);
|
||||
"}\n", "test.c");
|
||||
ASSERT_EQUALS("[test.c:4]: (error) Uninitialized struct member: ab.a\n", errout.str());
|
||||
|
||||
checkUninitVar2("struct AB { int a; int b; };\n"
|
||||
"void f(void) {\n"
|
||||
" struct AB ab;\n"
|
||||
" buf[ab.a] = 0;\n"
|
||||
"}\n", "test.c", true);
|
||||
"}\n", "test.c");
|
||||
ASSERT_EQUALS("[test.c:4]: (error) Uninitialized struct member: ab.a\n", errout.str());
|
||||
|
||||
checkUninitVar2("struct AB { int a; int b; };\n" // pass struct member by address
|
||||
"void f(void) {\n"
|
||||
" struct AB ab;\n"
|
||||
" assign(&ab.a, 0);\n"
|
||||
"}\n", "test.c", true);
|
||||
"}\n", "test.c");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar2("struct AB { int a; int b; };\n"
|
||||
|
@ -2605,7 +2612,7 @@ private:
|
|||
" ab.a = 0;\n"
|
||||
" ab.b = 0;\n"
|
||||
" do_something(ab);\n"
|
||||
"}\n", "test.c", true);
|
||||
"}\n", "test.c");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar2("struct AB { int a; int b; };\n"
|
||||
|
@ -2614,7 +2621,7 @@ private:
|
|||
" struct AB ab;\n"
|
||||
" ab = getAB();\n"
|
||||
" do_something(ab);\n"
|
||||
"}\n", "test.c", true);
|
||||
"}\n", "test.c");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar2("struct AB { int a; struct { int b; int c; } s; };\n"
|
||||
|
@ -2625,7 +2632,7 @@ private:
|
|||
" ab.s.b = 2;\n"
|
||||
" ab.s.c = 3;\n"
|
||||
" do_something(ab);\n"
|
||||
"}\n", "test.c", true);
|
||||
"}\n", "test.c");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar2("struct conf {\n"
|
||||
|
@ -2638,7 +2645,7 @@ private:
|
|||
" struct conf c;\n"
|
||||
" initdata(&c);\n"
|
||||
" do_something(c);\n"
|
||||
"}\n", "test.c", true);
|
||||
"}\n", "test.c");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// return
|
||||
|
@ -2647,7 +2654,7 @@ private:
|
|||
" struct AB ab;\n"
|
||||
" ab.a = 0;\n"
|
||||
" return ab.b;\n"
|
||||
"}\n", "test.c", true);
|
||||
"}\n", "test.c");
|
||||
ASSERT_EQUALS("[test.c:5]: (error) Uninitialized struct member: ab.b\n", errout.str());
|
||||
|
||||
checkUninitVar2("struct AB { int a; int b; };\n"
|
||||
|
@ -2655,7 +2662,7 @@ private:
|
|||
" struct AB ab;\n"
|
||||
" ab.a = 0;\n"
|
||||
" return ab.a;\n"
|
||||
"}\n", "test.c", true);
|
||||
"}\n", "test.c");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// checkIfForWhileHead
|
||||
|
@ -2668,7 +2675,7 @@ private:
|
|||
" struct FRED fred;\n"
|
||||
" fred.a = do_something();\n"
|
||||
" if (fred.a == 0) { }\n"
|
||||
"}\n", "test.c", true);
|
||||
"}\n", "test.c");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar2("struct FRED {\n"
|
||||
|
@ -2680,7 +2687,7 @@ private:
|
|||
" struct FRED fred;\n"
|
||||
" fred.a = do_something();\n"
|
||||
" if (fred.b == 0) { }\n"
|
||||
"}\n", "test.c", true);
|
||||
"}\n", "test.c");
|
||||
ASSERT_EQUALS("[test.c:9]: (error) Uninitialized struct member: fred.b\n", errout.str());
|
||||
|
||||
checkUninitVar2("struct S { int n; int m; };\n"
|
||||
|
|
|
@ -339,11 +339,11 @@ private:
|
|||
" {\n"
|
||||
" private:\n"
|
||||
" };\n"
|
||||
"\n"
|
||||
"private:\n"
|
||||
" static void f()\n"
|
||||
" { }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:10]: (style) Unused private function: 'A::f'\n", errout.str());
|
||||
|
||||
check("class A\n"
|
||||
"{\n"
|
||||
|
@ -452,6 +452,16 @@ private:
|
|||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("struct Bar {\n"
|
||||
" void g() { f(); }\n" // Friend class seen, but f not seen
|
||||
"};\n"
|
||||
"class Foo {\n"
|
||||
"private:\n"
|
||||
" friend Bar;\n"
|
||||
" void f();\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("struct Bar {\n"
|
||||
" void g() { f(); }\n" // Friend class seen, but f() used in it
|
||||
"};\n"
|
||||
|
|
|
@ -102,6 +102,7 @@ private:
|
|||
TEST_CASE(localvaralias8);
|
||||
TEST_CASE(localvaralias9); // ticket #1996
|
||||
TEST_CASE(localvaralias10); // ticket #2004
|
||||
TEST_CASE(localvaralias11); // ticket #4423 - iterator
|
||||
TEST_CASE(localvarasm);
|
||||
TEST_CASE(localvarstatic);
|
||||
TEST_CASE(localvarextern);
|
||||
|
@ -2718,6 +2719,14 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvaralias11() { // #4423 - iterator
|
||||
functionVariableUsage("void f(Foo &foo) {\n"
|
||||
" std::set<int>::iterator x = foo.dostuff();\n"
|
||||
" *(x) = 0;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvarasm() {
|
||||
functionVariableUsage("void foo(int &b)\n"
|
||||
"{\n"
|
||||
|
|
|
@ -102,19 +102,18 @@
|
|||
<ComponentRef Id='BaseDocs' />
|
||||
<ComponentRef Id='InnoSetupCleanup' />
|
||||
</Feature>
|
||||
<Feature Id='CLI' Title='Command line interface' AllowAdvertise='no' Description='Command line tool' Level='1'>
|
||||
<Feature Id='CLI' Title='Command line interface' AllowAdvertise='no' Description='Cppcheck as a command line tool' Level='1'>
|
||||
<ComponentRef Id='cppcheck.exe' />
|
||||
</Feature>
|
||||
<Feature Id='GUI' Title='Graphical interface' AllowAdvertise='no' Description='GUI for cppcheck' Level='1'>
|
||||
<Feature Id='GUI' Title='Graphical interface' AllowAdvertise='no' Description='Cppcheck with a graphical user interface' Level='1'>
|
||||
<ComponentRef Id='RegistryEntries' />
|
||||
<ComponentRef Id='GuiExecutable' />
|
||||
<Feature Id='Translations' Title='GUI Translations' AllowAdvertise='no' Description='Translations for cppcheck GUI' Level='1'>
|
||||
<Feature Id='Translations' Title='GUI Translations' AllowAdvertise='no' Description='Translations for graphical user interface' Level='1'>
|
||||
<ComponentRef Id='GuiTranslations' />
|
||||
</Feature>
|
||||
<ComponentRef Id='BaseDocs' />
|
||||
<ComponentRef Id='ProgramMenuDir' />
|
||||
</Feature>
|
||||
<Feature Id="CRT" AllowAdvertise="no" Display="hidden" Level="1" Title="Microsoft Visual C++ 2010 Runtime Components ">
|
||||
<Feature Id="CRT" AllowAdvertise="no" Display="hidden" Level="1" Title="Microsoft Visual C++ 2010 Runtime Components">
|
||||
<MergeRef Id="CRT"/>
|
||||
</Feature>
|
||||
</Feature>
|
||||
|
|
Loading…
Reference in New Issue