Cppcheck
|
#include "config.h"
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <initializer_list>
#include <limits>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <vector>
Go to the source code of this file.
Classes | |
struct | SelectMapKeys |
struct | SelectMapValues |
struct | OnExit |
struct | EnumClassHash |
Namespaces | |
cppcheck | |
Functions | |
template<class Range , class T > | |
bool | contains (const Range &r, const T &x) |
template<class T > | |
bool | contains (const std::initializer_list< T > &r, const T &x) |
template<class T , class U > | |
bool | contains (const std::initializer_list< T > &r, const U &x) |
template<class T , class ... Ts> | |
std::array< T, sizeof...(Ts)+1 > | makeArray (T x, Ts... xs) |
bool | startsWith (const std::string &str, const char start[], std::size_t startlen) |
template<std::size_t N> | |
bool | startsWith (const std::string &str, const char(&start)[N]) |
bool | startsWith (const std::string &str, const std::string &start) |
bool | endsWith (const std::string &str, char c) |
bool | endsWith (const std::string &str, const char end[], std::size_t endlen) |
template<std::size_t N> | |
bool | endsWith (const std::string &str, const char(&end)[N]) |
static bool | isPrefixStringCharLiteral (const std::string &str, char q, const std::string &p) |
static bool | isStringCharLiteral (const std::string &str, char q) |
static bool | isStringLiteral (const std::string &str) |
static bool | isCharLiteral (const std::string &str) |
static std::string | getStringCharLiteral (const std::string &str, char q) |
static std::string | getStringLiteral (const std::string &str) |
static std::string | getCharLiteral (const std::string &str) |
static const char * | getOrdinalText (int i) |
CPPCHECKLIB int | caseInsensitiveStringCompare (const std::string &lhs, const std::string &rhs) |
CPPCHECKLIB bool | isValidGlobPattern (const std::string &pattern) |
CPPCHECKLIB bool | matchglob (const std::string &pattern, const std::string &name) |
CPPCHECKLIB bool | matchglobs (const std::vector< std::string > &patterns, const std::string &name) |
CPPCHECKLIB void | strTolower (std::string &str) |
template<typename T , typename std::enable_if< std::is_signed< T >::value, bool >::type = true> | |
bool | strToInt (const std::string &str, T &num, std::string *err=nullptr) |
template<typename T > | |
T | strToInt (const std::string &str) |
template<typename T , int size> | |
std::size_t | getArrayLength (const T(&)[size]) |
Simple helper function: More... | |
static std::string | id_string_i (std::uintptr_t l) |
get id string. More... | |
static std::string | id_string (const void *p) |
static const char * | bool_to_string (bool b) |
CPPCHECKLIB std::string | trim (const std::string &s, const std::string &t=" \t") |
Remove heading and trailing whitespaces from the input parameter. More... | |
CPPCHECKLIB void | findAndReplace (std::string &source, const std::string &searchFor, const std::string &replaceWith) |
Replace all occurrences of searchFor with replaceWith in the given source. More... | |
NORETURN void | cppcheck::unreachable () |
template<typename T > | |
static T * | empty_if_null (T *p) |
|
inlinestatic |
Definition at line 345 of file utils.h.
Referenced by CheckCondition::alwaysTrueFalseError(), CheckCondition::assignIfError(), ValueFlowAnalyzer::assume(), CheckOther::checkComparisonFunctionIsAlwaysTrueOrFalseError(), CheckCondition::checkInvalidTestForOverflow(), CheckCondition::compareValueOutOfTypeRangeError(), CheckCondition::comparisonError(), Preprocessor::dump(), Tokenizer::dump(), LibraryDialog::getArgText(), CheckString::incorrectStringBooleanError(), CheckOther::knownPointerToBoolError(), SymbolDatabase::printXml(), TemplateSimplifier::simplifyTemplateArgs(), ProjectFile::write(), writeFunction(), and writeMemoryResource().
CPPCHECKLIB int caseInsensitiveStringCompare | ( | const std::string & | lhs, |
const std::string & | rhs | ||
) |
Definition at line 28 of file utils.cpp.
Referenced by cppcheck::stricmp::operator()(), and Path::sameFileName().
bool contains | ( | const Range & | r, |
const T & | x | ||
) |
Definition at line 62 of file utils.h.
Referenced by containerAppendsElement(), containerPopsElement(), clangimport::AstNode::createScope(), clangimport::AstNode::createTokens(), clangimport::AstNode::createTokensForCXXRecord(), clangimport::AstNode::createTokensFunctionDecl(), clangimport::AstNode::createTokensVarDecl(), evaluate(), exprDependsOnThis(), Scope::findAssociatedScopes(), getInnerLifetime(), clangimport::AstNode::isDefinition(), isElementAccessYield(), ValueFlowAnalyzer::isModified(), isVariableChanged(), loadPlatformType(), setTokenValue(), valueFlowLifetime(), and valueFlowLifetimeFunction().
bool contains | ( | const std::initializer_list< T > & | r, |
const T & | x | ||
) |
bool contains | ( | const std::initializer_list< T > & | r, |
const U & | x | ||
) |
|
inlinestatic |
Definition at line 382 of file utils.h.
Referenced by CmdLineParser::parseFromArgs().
|
inline |
Definition at line 110 of file utils.h.
Referenced by FileLister::addFiles(), addIncludePathsToList(), CheckClass::checkConst(), CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(), CheckString::checkIncorrectStringCompare(), Tokenizer::combineOperators(), endsWith(), CppCheck::executeAddons(), ImportProject::fsParseCommand(), ImportProject::fsSetDefines(), ImportProject::fsSetIncludePaths(), Function::Function(), AddonInfo::getAddonInfo(), AnalyzerInformation::getAnalyzerInfoFileFromFilesTxt(), Path::getRelativePath(), ImportProject::import(), ImportProject::importCompileCommands(), isCPPCastKeyword(), SymbolDatabase::isFunction(), Tokenizer::isFunctionHead(), isPrefixStringCharLiteral(), isStringCharLiteral(), Library::load(), PathMatch::match(), clangimport::parseClangAstDump(), parsedecl(), CmdLineParser::parseFromArgs(), Tokenizer::removeMacrosInGlobalScope(), ErrorMessage::setmsg(), and Tokenizer::setVarIdPass1().
|
inline |
bool endsWith | ( | const std::string & | str, |
const char(&) | end[N] | ||
) |
Definition at line 121 of file utils.h.
References endsWith().
CPPCHECKLIB void findAndReplace | ( | std::string & | source, |
const std::string & | searchFor, | ||
const std::string & | replaceWith | ||
) |
Replace all occurrences of searchFor with replaceWith in the given source.
source | The string to modify |
searchFor | What should be searched for |
replaceWith | What will replace the found item |
Definition at line 142 of file utils.cpp.
Referenced by ErrorMessage::toString().
std::size_t getArrayLength | ( | const | T(&)[size] | ) |
|
inlinestatic |
Definition at line 182 of file utils.h.
References getStringCharLiteral(), and isCharLiteral().
Referenced by CheckString::incorrectStringBooleanError().
|
inlinestatic |
Definition at line 189 of file utils.h.
Referenced by CheckBufferOverrun::argumentSizeError(), CTU::FileInfo::getErrorPath(), and valueFlowSubFunction().
|
inlinestatic |
Definition at line 169 of file utils.h.
Referenced by getCharLiteral(), and getStringLiteral().
|
inlinestatic |
Definition at line 175 of file utils.h.
References getStringCharLiteral(), and isStringLiteral().
Referenced by Token::concatStr(), createBuiltinLibraryFunctions(), Token::getStrArraySize(), Token::getStrLength(), and Token::strValue().
|
inlinestatic |
Definition at line 340 of file utils.h.
References id_string_i().
Referenced by ValueType::dump(), Tokenizer::dump(), Token::printValueFlow(), and SymbolDatabase::printXml().
|
inlinestatic |
get id string.
i.e. for dump files it will be a hexadecimal output.
Definition at line 305 of file utils.h.
Referenced by id_string().
|
inlinestatic |
Definition at line 164 of file utils.h.
References isStringCharLiteral().
Referenced by getCharLiteral(), CheckString::incorrectStringBooleanError(), MathLib::toBigNumber(), MathLib::toBigUNumber(), MathLib::toDoubleNumber(), and Token::update_property_info().
|
inlinestatic |
Definition at line 126 of file utils.h.
References endsWith().
Referenced by Token::isCChar(), Token::isCMultiChar(), Token::isUtf16(), Token::isUtf32(), Token::isUtf8(), and Token::update_property_char_string_literal().
|
inlinestatic |
Definition at line 147 of file utils.h.
References endsWith().
Referenced by isCharLiteral(), and isStringLiteral().
|
inlinestatic |
Definition at line 159 of file utils.h.
References isStringCharLiteral().
Referenced by Tokenizer::combineStringAndCharLiterals(), Token::concatStr(), getStringLiteral(), and Token::update_property_info().
CPPCHECKLIB bool isValidGlobPattern | ( | const std::string & | pattern | ) |
Definition at line 41 of file utils.cpp.
Referenced by SuppressionList::addSuppression(), and ImportProject::ignorePaths().
|
inline |
Definition at line 80 of file utils.h.
Referenced by valueFlowImpossibleValues().
CPPCHECKLIB bool matchglob | ( | const std::string & | pattern, |
const std::string & | name | ||
) |
Definition at line 54 of file utils.cpp.
Referenced by ImportProject::ignorePaths(), SuppressionList::Suppression::isSuppressed(), and matchglobs().
CPPCHECKLIB bool matchglobs | ( | const std::vector< std::string > & | patterns, |
const std::string & | name | ||
) |
Definition at line 118 of file utils.cpp.
References matchglob().
Referenced by ImportProject::importVcxproj().
|
inline |
Definition at line 94 of file utils.h.
Referenced by clangimport::AstNode::addTypeTokens(), CppCheck::checkFile(), CheckUnusedVar::checkFunctionVariableUsage(), CheckLeakAutoVar::checkTokenInsideExpression(), createTokenFromExpression(), clangimport::AstNode::createTokens(), Library::detectContainerInternal(), detectPython(), Tokenizer::duplicateTypedef(), ErrorMessage::ErrorMessage(), executeAddon(), CppCheck::executeAddons(), CheckThread::executeCommand(), ImportProject::fsParseCommand(), ImportProject::fsSetIncludePaths(), Library::getFunctionName(), clangimport::AstNode::getSpelling(), SuppressionList::Suppression::getText(), gotoEndIf(), ImportProject::importSln(), Path::isAbsolute(), Scope::isAnonymous(), CmdLineParser::isCppcheckPremium(), Path::isHeader(), isNonMacro(), isOperator(), CppCheck::isPremiumCodingStandardId(), isVariableChangedByFunctionCall(), SuppressionList::Suppression::parseComment(), CmdLineParser::parseFromArgs(), SuppressionList::parseMultiSuppressComment(), Preprocessor::reportOutput(), Tokenizer::reportUnknownMacros(), CheckThread::runAddonsAndTools(), ImportProject::selectOneVsConfig(), clangimport::AstNode::setLocations(), ErrorMessage::setmsg(), TimerResults::showResults(), startsWith(), and valueFlowLifetimeFunction().
bool startsWith | ( | const std::string & | str, |
const char(&) | start[N] | ||
) |
Definition at line 100 of file utils.h.
References startsWith().
|
inline |
Definition at line 105 of file utils.h.
References startsWith().
T strToInt | ( | const std::string & | str | ) |
Definition at line 281 of file utils.h.
References strToInt().
bool strToInt | ( | const std::string & | str, |
T & | num, | ||
std::string * | err = nullptr |
||
) |
Definition at line 211 of file utils.h.
Referenced by ErrorMessage::deserialize(), CmdLineParser::parseFromArgs(), CmdLineParser::parseNumberArg(), and strToInt().
CPPCHECKLIB void strTolower | ( | std::string & | str | ) |
Definition at line 124 of file utils.cpp.
Referenced by CheckOther::checkKnownArgument(), Path::getFilenameExtension(), Path::identify(), PathMatch::match(), PathMatch::PathMatch(), and Standards::setCPP().
CPPCHECKLIB std::string trim | ( | const std::string & | s, |
const std::string & | t = " \t" |
||
) |