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

Function needsInitialization

lib/valueflow.cpp:5894–5926  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5892}
5893
5894static bool needsInitialization(const Variable* var)
5895{
5896 if (!var)
5897 return false;
5898 if (var->hasDefault())
5899 return false;
5900 if (var->isPointer())
5901 return true;
5902 if (var->type() && var->type()->isUnionType())
5903 return false;
5904 if (!var->nameToken()->isCpp())
5905 return true;
5906 if (var->type() && var->type()->needInitialization == Type::NeedInitialization::True)
5907 return true;
5908 if (var->valueType()) {
5909 if (var->valueType()->isPrimitive())
5910 return true;
5911 if (var->valueType()->type == ValueType::Type::POD)
5912 return true;
5913 if (var->valueType()->type == ValueType::Type::ITERATOR)
5914 return true;
5915 if (var->isStlType() && var->isArray()) {
5916 if (const Token* ctt = var->valueType()->containerTypeToken) {
5917 if (ctt->isStandardType())
5918 return true;
5919 const Type* ct = ctt->type();
5920 if (ct && ct->needInitialization == Type::NeedInitialization::True)
5921 return true;
5922 }
5923 }
5924 }
5925 return false;
5926}
5927
5928static void addToErrorPath(ValueFlow::Value& value, const ValueFlow::Value& from)
5929{

Callers 1

valueFlowUninitFunction · 0.85

Calls 5

typeMethod · 0.80
isUnionTypeMethod · 0.80
isArrayMethod · 0.80
nameTokenMethod · 0.45
isStandardTypeMethod · 0.45

Tested by

no test coverage detected