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

Method analyseWholeProgram

lib/checkuninitvar.cpp:1752–1798  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1750}
1751
1752bool CheckUninitVar::analyseWholeProgram(const CTU::FileInfo &ctu, const std::list<const Check::FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger)
1753{
1754 (void)settings;
1755
1756 CheckUninitVarImpl dummy(nullptr, settings, errorLogger);
1757 dummy.
1758 logChecker("CheckUninitVar::analyseWholeProgram");
1759
1760 if (fileInfo.empty())
1761 return false;
1762
1763 const std::map<std::string, std::list<const CTU::FileInfo::CallBase *>> callsMap = ctu.getCallsMap();
1764
1765 bool foundErrors = false;
1766
1767 for (const Check::FileInfo* fi1 : fileInfo) {
1768 const auto *fi = dynamic_cast<const MyFileInfo*>(fi1);
1769 if (!fi)
1770 continue;
1771 for (const CTU::FileInfo::UnsafeUsage &unsafeUsage : fi->unsafeUsage) {
1772 const CTU::FileInfo::FunctionCall *functionCall = nullptr;
1773
1774 std::list<ErrorMessage::FileLocation> locationList =
1775 CTU::FileInfo::getErrorPath(CTU::FileInfo::InvalidValueType::uninit,
1776 unsafeUsage,
1777 callsMap,
1778 "Using argument ARG",
1779 &functionCall,
1780 false,
1781 settings.maxCtuDepth);
1782 if (locationList.empty())
1783 continue;
1784
1785 const ErrorMessage errmsg(std::move(locationList),
1786 fi->file0,
1787 Severity::error,
1788 "Using argument " + unsafeUsage.myArgumentName + " that points at uninitialized variable " + functionCall->callArgumentExpression,
1789 "ctuuninitvar",
1790 CWE_USE_OF_UNINITIALIZED_VARIABLE,
1791 Certainty::normal);
1792 errorLogger.reportErr(errmsg);
1793
1794 foundErrors = true;
1795 }
1796 }
1797 return foundErrors;
1798}
1799
1800void CheckUninitVar::runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger)
1801{

Callers

nothing calls this directly

Calls 4

logCheckerMethod · 0.80
getCallsMapMethod · 0.80
emptyMethod · 0.45
reportErrMethod · 0.45

Tested by

no test coverage detected