MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / analyseWholeProgram

Method analyseWholeProgram

lib/checkbufferoverrun.cpp:993–1016  ·  view source on GitHub ↗

@brief Analyse all file infos for all TU */

Source from the content-addressed store, hash-verified

991
992/** @brief Analyse all file infos for all TU */
993bool CheckBufferOverrun::analyseWholeProgram(const CTU::FileInfo &ctu, const std::list<const Check::FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger)
994{
995 CheckBufferOverrunImpl dummy(nullptr, settings, errorLogger);
996 dummy.
997 logChecker("CheckBufferOverrun::analyseWholeProgram");
998
999 if (fileInfo.empty())
1000 return false;
1001
1002 const std::map<std::string, std::list<const CTU::FileInfo::CallBase *>> callsMap = ctu.getCallsMap();
1003
1004 bool foundErrors = false;
1005
1006 for (const Check::FileInfo* fi1 : fileInfo) {
1007 const auto *fi = dynamic_cast<const MyFileInfo*>(fi1);
1008 if (!fi)
1009 continue;
1010 for (const CTU::FileInfo::UnsafeUsage &unsafeUsage : fi->unsafeArrayIndex)
1011 foundErrors |= analyseWholeProgram1(callsMap, unsafeUsage, 1, errorLogger, settings.maxCtuDepth, fi->file0);
1012 for (const CTU::FileInfo::UnsafeUsage &unsafeUsage : fi->unsafePointerArith)
1013 foundErrors |= analyseWholeProgram1(callsMap, unsafeUsage, 2, errorLogger, settings.maxCtuDepth, fi->file0);
1014 }
1015 return foundErrors;
1016}
1017
1018bool CheckBufferOverrun::analyseWholeProgram1(const std::map<std::string, std::list<const CTU::FileInfo::CallBase *>> &callsMap, const CTU::FileInfo::UnsafeUsage &unsafeUsage,
1019 int type, ErrorLogger &errorLogger, int maxCtuDepth, const std::string& file0)

Callers

nothing calls this directly

Calls 3

logCheckerMethod · 0.80
getCallsMapMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected