moved `MyFileInfo` definitions into source files (#4697)
This commit is contained in:
parent
26ba29c303
commit
09785a4eb8
6
Makefile
6
Makefile
|
@ -458,7 +458,7 @@ validateRules:
|
||||||
|
|
||||||
###### Build
|
###### Build
|
||||||
|
|
||||||
$(libcppdir)/valueflow.o: lib/valueflow.cpp lib/addoninfo.h lib/analyzer.h lib/astutils.h lib/calculate.h lib/check.h lib/checkuninitvar.h lib/color.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/findtoken.h lib/forwardanalyzer.h lib/importproject.h lib/infer.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/programmemory.h lib/reverseanalyzer.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/valueptr.h lib/vfvalue.h
|
$(libcppdir)/valueflow.o: lib/valueflow.cpp lib/addoninfo.h lib/analyzer.h lib/astutils.h lib/calculate.h lib/check.h lib/checkuninitvar.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/findtoken.h lib/forwardanalyzer.h lib/importproject.h lib/infer.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/programmemory.h lib/reverseanalyzer.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/valueptr.h lib/vfvalue.h
|
||||||
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/valueflow.cpp
|
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/valueflow.cpp
|
||||||
|
|
||||||
$(libcppdir)/tokenize.o: lib/tokenize.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/summaries.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h
|
$(libcppdir)/tokenize.o: lib/tokenize.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/summaries.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h
|
||||||
|
@ -521,7 +521,7 @@ $(libcppdir)/checkinternal.o: lib/checkinternal.cpp lib/addoninfo.h lib/astutils
|
||||||
$(libcppdir)/checkio.o: lib/checkio.cpp lib/addoninfo.h lib/check.h lib/checkio.h lib/config.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
|
$(libcppdir)/checkio.o: lib/checkio.cpp lib/addoninfo.h lib/check.h lib/checkio.h lib/config.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
|
||||||
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkio.cpp
|
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkio.cpp
|
||||||
|
|
||||||
$(libcppdir)/checkleakautovar.o: lib/checkleakautovar.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkleakautovar.h lib/checkmemoryleak.h lib/checknullpointer.h lib/color.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
|
$(libcppdir)/checkleakautovar.o: lib/checkleakautovar.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkleakautovar.h lib/checkmemoryleak.h lib/checknullpointer.h lib/config.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
|
||||||
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkleakautovar.cpp
|
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkleakautovar.cpp
|
||||||
|
|
||||||
$(libcppdir)/checkmemoryleak.o: lib/checkmemoryleak.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkmemoryleak.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
|
$(libcppdir)/checkmemoryleak.o: lib/checkmemoryleak.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkmemoryleak.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
|
||||||
|
@ -539,7 +539,7 @@ $(libcppdir)/checkpostfixoperator.o: lib/checkpostfixoperator.cpp lib/addoninfo.
|
||||||
$(libcppdir)/checksizeof.o: lib/checksizeof.cpp lib/addoninfo.h lib/check.h lib/checksizeof.h lib/config.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
|
$(libcppdir)/checksizeof.o: lib/checksizeof.cpp lib/addoninfo.h lib/check.h lib/checksizeof.h lib/config.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
|
||||||
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checksizeof.cpp
|
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checksizeof.cpp
|
||||||
|
|
||||||
$(libcppdir)/checkstl.o: lib/checkstl.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checknullpointer.h lib/checkstl.h lib/color.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/pathanalysis.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h
|
$(libcppdir)/checkstl.o: lib/checkstl.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checknullpointer.h lib/checkstl.h lib/config.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/pathanalysis.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h
|
||||||
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkstl.cpp
|
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkstl.cpp
|
||||||
|
|
||||||
$(libcppdir)/checkstring.o: lib/checkstring.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkstring.h lib/config.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
|
$(libcppdir)/checkstring.o: lib/checkstring.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkstring.h lib/config.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
|
||||||
|
|
|
@ -883,14 +883,27 @@ void CheckBufferOverrun::argumentSizeError(const Token *tok, const std::string &
|
||||||
// CTU..
|
// CTU..
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
std::string CheckBufferOverrun::MyFileInfo::toString() const
|
namespace {
|
||||||
{
|
/** data for multifile checking */
|
||||||
std::string xml;
|
class MyFileInfo : public Check::FileInfo {
|
||||||
if (!unsafeArrayIndex.empty())
|
public:
|
||||||
xml = " <array-index>\n" + CTU::toString(unsafeArrayIndex) + " </array-index>\n";
|
/** unsafe array index usage */
|
||||||
if (!unsafePointerArith.empty())
|
std::list<CTU::FileInfo::UnsafeUsage> unsafeArrayIndex;
|
||||||
xml += " <pointer-arith>\n" + CTU::toString(unsafePointerArith) + " </pointer-arith>\n";
|
|
||||||
return xml;
|
/** unsafe pointer arithmetics */
|
||||||
|
std::list<CTU::FileInfo::UnsafeUsage> unsafePointerArith;
|
||||||
|
|
||||||
|
/** Convert data into xml string */
|
||||||
|
std::string toString() const override
|
||||||
|
{
|
||||||
|
std::string xml;
|
||||||
|
if (!unsafeArrayIndex.empty())
|
||||||
|
xml = " <array-index>\n" + CTU::toString(unsafeArrayIndex) + " </array-index>\n";
|
||||||
|
if (!unsafePointerArith.empty())
|
||||||
|
xml += " <pointer-arith>\n" + CTU::toString(unsafePointerArith) + " </pointer-arith>\n";
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckBufferOverrun::isCtuUnsafeBufferUsage(const Check *check, const Token *argtok, MathLib::bigint *offset, int type)
|
bool CheckBufferOverrun::isCtuUnsafeBufferUsage(const Check *check, const Token *argtok, MathLib::bigint *offset, int type)
|
||||||
|
|
|
@ -130,20 +130,6 @@ private:
|
||||||
ValueFlow::Value getBufferSize(const Token *bufTok) const;
|
ValueFlow::Value getBufferSize(const Token *bufTok) const;
|
||||||
|
|
||||||
// CTU
|
// CTU
|
||||||
|
|
||||||
/** data for multifile checking */
|
|
||||||
class MyFileInfo : public Check::FileInfo {
|
|
||||||
public:
|
|
||||||
/** unsafe array index usage */
|
|
||||||
std::list<CTU::FileInfo::UnsafeUsage> unsafeArrayIndex;
|
|
||||||
|
|
||||||
/** unsafe pointer arithmetic */
|
|
||||||
std::list<CTU::FileInfo::UnsafeUsage> unsafePointerArith;
|
|
||||||
|
|
||||||
/** Convert MyFileInfo data into xml string */
|
|
||||||
std::string toString() const override;
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool isCtuUnsafeBufferUsage(const Check *check, const Token *argtok, MathLib::bigint *offset, int type);
|
static bool isCtuUnsafeBufferUsage(const Check *check, const Token *argtok, MathLib::bigint *offset, int type);
|
||||||
static bool isCtuUnsafeArrayIndex(const Check *check, const Token *argtok, MathLib::bigint *offset);
|
static bool isCtuUnsafeArrayIndex(const Check *check, const Token *argtok, MathLib::bigint *offset);
|
||||||
static bool isCtuUnsafePointerArith(const Check *check, const Token *argtok, MathLib::bigint *offset);
|
static bool isCtuUnsafePointerArith(const Check *check, const Token *argtok, MathLib::bigint *offset);
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
#include <cstddef>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
@ -3390,6 +3391,42 @@ void CheckClass::unsafeClassRefMemberError(const Token *tok, const std::string &
|
||||||
CWE(0), Certainty::normal);
|
CWE(0), Certainty::normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
/* multifile checking; one definition rule violations */
|
||||||
|
class MyFileInfo : public Check::FileInfo {
|
||||||
|
public:
|
||||||
|
struct NameLoc {
|
||||||
|
std::string className;
|
||||||
|
std::string fileName;
|
||||||
|
int lineNumber;
|
||||||
|
int column;
|
||||||
|
std::size_t hash;
|
||||||
|
|
||||||
|
bool isSameLocation(const NameLoc& other) const {
|
||||||
|
return fileName == other.fileName &&
|
||||||
|
lineNumber == other.lineNumber &&
|
||||||
|
column == other.column;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
std::vector<NameLoc> classDefinitions;
|
||||||
|
|
||||||
|
/** Convert data into xml string */
|
||||||
|
std::string toString() const override
|
||||||
|
{
|
||||||
|
std::string ret;
|
||||||
|
for (const NameLoc &nameLoc: classDefinitions) {
|
||||||
|
ret += "<class name=\"" + ErrorLogger::toxml(nameLoc.className) +
|
||||||
|
"\" file=\"" + ErrorLogger::toxml(nameLoc.fileName) +
|
||||||
|
"\" line=\"" + std::to_string(nameLoc.lineNumber) +
|
||||||
|
"\" col=\"" + std::to_string(nameLoc.column) +
|
||||||
|
"\" hash=\"" + std::to_string(nameLoc.hash) +
|
||||||
|
"\"/>\n";
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
Check::FileInfo *CheckClass::getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const
|
Check::FileInfo *CheckClass::getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const
|
||||||
{
|
{
|
||||||
if (!tokenizer->isCPP())
|
if (!tokenizer->isCPP())
|
||||||
|
@ -3459,20 +3496,6 @@ Check::FileInfo *CheckClass::getFileInfo(const Tokenizer *tokenizer, const Setti
|
||||||
return fileInfo;
|
return fileInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CheckClass::MyFileInfo::toString() const
|
|
||||||
{
|
|
||||||
std::string ret;
|
|
||||||
for (const MyFileInfo::NameLoc &nameLoc: classDefinitions) {
|
|
||||||
ret += "<class name=\"" + ErrorLogger::toxml(nameLoc.className) +
|
|
||||||
"\" file=\"" + ErrorLogger::toxml(nameLoc.fileName) +
|
|
||||||
"\" line=\"" + std::to_string(nameLoc.lineNumber) +
|
|
||||||
"\" col=\"" + std::to_string(nameLoc.column) +
|
|
||||||
"\" hash=\"" + std::to_string(nameLoc.hash) +
|
|
||||||
"\"/>\n";
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
Check::FileInfo * CheckClass::loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const
|
Check::FileInfo * CheckClass::loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const
|
||||||
{
|
{
|
||||||
MyFileInfo *fileInfo = new MyFileInfo;
|
MyFileInfo *fileInfo = new MyFileInfo;
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include "tokenize.h"
|
#include "tokenize.h"
|
||||||
#include "symboldatabase.h"
|
#include "symboldatabase.h"
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
@ -164,33 +163,6 @@ private:
|
||||||
/** @brief Unsafe class check - const reference member */
|
/** @brief Unsafe class check - const reference member */
|
||||||
void checkUnsafeClassRefMember();
|
void checkUnsafeClassRefMember();
|
||||||
|
|
||||||
|
|
||||||
/* multifile checking; one definition rule violations */
|
|
||||||
class MyFileInfo : public Check::FileInfo {
|
|
||||||
public:
|
|
||||||
struct NameLoc {
|
|
||||||
std::string className;
|
|
||||||
std::string fileName;
|
|
||||||
int lineNumber;
|
|
||||||
int column;
|
|
||||||
std::size_t hash;
|
|
||||||
|
|
||||||
bool operator==(const NameLoc& other) const {
|
|
||||||
return isSameLocation(other) && hash == other.hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isSameLocation(const NameLoc& other) const {
|
|
||||||
return fileName == other.fileName &&
|
|
||||||
lineNumber == other.lineNumber &&
|
|
||||||
column == other.column;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
std::vector<NameLoc> classDefinitions;
|
|
||||||
|
|
||||||
/** Convert MyFileInfo data into xml string */
|
|
||||||
std::string toString() const override;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @brief Parse current TU and extract file info */
|
/** @brief Parse current TU and extract file info */
|
||||||
Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const override;
|
Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const override;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "checknullpointer.h"
|
#include "checknullpointer.h"
|
||||||
|
|
||||||
#include "astutils.h"
|
#include "astutils.h"
|
||||||
|
#include "ctu.h"
|
||||||
#include "errorlogger.h"
|
#include "errorlogger.h"
|
||||||
#include "errortypes.h"
|
#include "errortypes.h"
|
||||||
#include "library.h"
|
#include "library.h"
|
||||||
|
@ -547,11 +548,6 @@ void CheckNullPointer::redundantConditionWarning(const Token* tok, const ValueFl
|
||||||
inconclusive ? Certainty::inconclusive : Certainty::normal);
|
inconclusive ? Certainty::inconclusive : Certainty::normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CheckNullPointer::MyFileInfo::toString() const
|
|
||||||
{
|
|
||||||
return CTU::toString(unsafeUsage);
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOLINTNEXTLINE(readability-non-const-parameter) - used as callback so we need to preserve the signature
|
// NOLINTNEXTLINE(readability-non-const-parameter) - used as callback so we need to preserve the signature
|
||||||
static bool isUnsafeUsage(const Check *check, const Token *vartok, MathLib::bigint *value)
|
static bool isUnsafeUsage(const Check *check, const Token *vartok, MathLib::bigint *value)
|
||||||
{
|
{
|
||||||
|
@ -561,6 +557,22 @@ static bool isUnsafeUsage(const Check *check, const Token *vartok, MathLib::bigi
|
||||||
return checkNullPointer && checkNullPointer->isPointerDeRef(vartok, unknown);
|
return checkNullPointer && checkNullPointer->isPointerDeRef(vartok, unknown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
/* data for multifile checking */
|
||||||
|
class MyFileInfo : public Check::FileInfo {
|
||||||
|
public:
|
||||||
|
/** function arguments that are dereferenced without checking if they are null */
|
||||||
|
std::list<CTU::FileInfo::UnsafeUsage> unsafeUsage;
|
||||||
|
|
||||||
|
/** Convert data into xml string */
|
||||||
|
std::string toString() const override
|
||||||
|
{
|
||||||
|
return CTU::toString(unsafeUsage);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Check::FileInfo *CheckNullPointer::getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const
|
Check::FileInfo *CheckNullPointer::getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const
|
||||||
{
|
{
|
||||||
CheckNullPointer check(tokenizer, settings, nullptr);
|
CheckNullPointer check(tokenizer, settings, nullptr);
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
#include "check.h"
|
#include "check.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "ctu.h"
|
|
||||||
#include "tokenize.h"
|
#include "tokenize.h"
|
||||||
#include "vfvalue.h"
|
#include "vfvalue.h"
|
||||||
|
|
||||||
|
@ -36,6 +35,10 @@ class Library;
|
||||||
class Settings;
|
class Settings;
|
||||||
class Token;
|
class Token;
|
||||||
|
|
||||||
|
namespace CTU {
|
||||||
|
class FileInfo;
|
||||||
|
}
|
||||||
|
|
||||||
namespace tinyxml2 {
|
namespace tinyxml2 {
|
||||||
class XMLElement;
|
class XMLElement;
|
||||||
}
|
}
|
||||||
|
@ -102,16 +105,6 @@ private:
|
||||||
}
|
}
|
||||||
void nullPointerError(const Token *tok, const std::string &varname, const ValueFlow::Value* value, bool inconclusive);
|
void nullPointerError(const Token *tok, const std::string &varname, const ValueFlow::Value* value, bool inconclusive);
|
||||||
|
|
||||||
/* data for multifile checking */
|
|
||||||
class MyFileInfo : public Check::FileInfo {
|
|
||||||
public:
|
|
||||||
/** function arguments that are dereferenced without checking if they are null */
|
|
||||||
std::list<CTU::FileInfo::UnsafeUsage> unsafeUsage;
|
|
||||||
|
|
||||||
/** Convert MyFileInfo data into xml string */
|
|
||||||
std::string toString() const override;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @brief Parse current TU and extract file info */
|
/** @brief Parse current TU and extract file info */
|
||||||
Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const override;
|
Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const override;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "checkuninitvar.h"
|
#include "checkuninitvar.h"
|
||||||
|
|
||||||
#include "astutils.h"
|
#include "astutils.h"
|
||||||
|
#include "ctu.h"
|
||||||
#include "errorlogger.h"
|
#include "errorlogger.h"
|
||||||
#include "library.h"
|
#include "library.h"
|
||||||
#include "mathlib.h"
|
#include "mathlib.h"
|
||||||
|
@ -1680,11 +1681,6 @@ void CheckUninitVar::valueFlowUninit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CheckUninitVar::MyFileInfo::toString() const
|
|
||||||
{
|
|
||||||
return CTU::toString(unsafeUsage);
|
|
||||||
}
|
|
||||||
|
|
||||||
Check::FileInfo *CheckUninitVar::getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const
|
Check::FileInfo *CheckUninitVar::getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const
|
||||||
{
|
{
|
||||||
const CheckUninitVar checker(tokenizer, settings, nullptr);
|
const CheckUninitVar checker(tokenizer, settings, nullptr);
|
||||||
|
@ -1699,6 +1695,21 @@ static bool isVariableUsage(const Check *check, const Token *vartok, MathLib::bi
|
||||||
return c && c->isVariableUsage(vartok, true, CheckUninitVar::Alloc::ARRAY);
|
return c && c->isVariableUsage(vartok, true, CheckUninitVar::Alloc::ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
/* data for multifile checking */
|
||||||
|
class MyFileInfo : public Check::FileInfo {
|
||||||
|
public:
|
||||||
|
/** function arguments that data are unconditionally read */
|
||||||
|
std::list<CTU::FileInfo::UnsafeUsage> unsafeUsage;
|
||||||
|
|
||||||
|
/** Convert data into xml string */
|
||||||
|
std::string toString() const override
|
||||||
|
{
|
||||||
|
return CTU::toString(unsafeUsage);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
Check::FileInfo *CheckUninitVar::getFileInfo() const
|
Check::FileInfo *CheckUninitVar::getFileInfo() const
|
||||||
{
|
{
|
||||||
const std::list<CTU::FileInfo::UnsafeUsage> &unsafeUsage = CTU::getUnsafeUsage(mTokenizer, mSettings, this, ::isVariableUsage);
|
const std::list<CTU::FileInfo::UnsafeUsage> &unsafeUsage = CTU::getUnsafeUsage(mTokenizer, mSettings, this, ::isVariableUsage);
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
#include "check.h"
|
#include "check.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "ctu.h"
|
|
||||||
#include "mathlib.h"
|
#include "mathlib.h"
|
||||||
#include "errortypes.h"
|
#include "errortypes.h"
|
||||||
#include "tokenize.h"
|
#include "tokenize.h"
|
||||||
|
@ -42,6 +41,10 @@ class ErrorLogger;
|
||||||
class Settings;
|
class Settings;
|
||||||
class Library;
|
class Library;
|
||||||
|
|
||||||
|
namespace CTU {
|
||||||
|
class FileInfo;
|
||||||
|
}
|
||||||
|
|
||||||
namespace tinyxml2 {
|
namespace tinyxml2 {
|
||||||
class XMLElement;
|
class XMLElement;
|
||||||
}
|
}
|
||||||
|
@ -102,16 +105,6 @@ private:
|
||||||
/** ValueFlow-based checking for uninitialized variables */
|
/** ValueFlow-based checking for uninitialized variables */
|
||||||
void valueFlowUninit();
|
void valueFlowUninit();
|
||||||
|
|
||||||
/* data for multifile checking */
|
|
||||||
class MyFileInfo : public Check::FileInfo {
|
|
||||||
public:
|
|
||||||
/** function arguments that data are unconditionally read */
|
|
||||||
std::list<CTU::FileInfo::UnsafeUsage> unsafeUsage;
|
|
||||||
|
|
||||||
/** Convert MyFileInfo data into xml string */
|
|
||||||
std::string toString() const override;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @brief Parse current TU and extract file info */
|
/** @brief Parse current TU and extract file info */
|
||||||
Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const override;
|
Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const override;
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class Tokenizer;
|
class Tokenizer;
|
||||||
|
|
Loading…
Reference in New Issue