| 112 | {} |
| 113 | |
| 114 | bool CheckClassImpl::isInitialized(const Usage& usage, FunctionType funcType) const |
| 115 | { |
| 116 | const Variable& var = *usage.var; |
| 117 | |
| 118 | if (usage.assign || usage.init || var.isStatic()) |
| 119 | return true; |
| 120 | |
| 121 | if (!var.nameToken() || var.nameToken()->isAnonymous()) |
| 122 | return true; |
| 123 | |
| 124 | if (var.valueType() && var.valueType()->pointer == 0 && var.type() && var.type()->needInitialization == Type::NeedInitialization::False && var.type()->derivedFrom.empty()) |
| 125 | return true; |
| 126 | |
| 127 | if (var.isConst() && funcType == FunctionType::eOperatorEqual) // We can't set const members in assignment operator |
| 128 | return true; |
| 129 | |
| 130 | // Check if this is a class constructor |
| 131 | if (!var.isPointer() && !var.isPointerArray() && var.isClass() && funcType == FunctionType::eConstructor) { |
| 132 | // Unknown type so assume it is initialized |
| 133 | if (!var.type()) { |
| 134 | if (var.isStlType() && var.valueType() && var.valueType()->containerTypeToken) { |
| 135 | if (var.valueType()->type == ValueType::Type::ITERATOR) |
| 136 | { |
| 137 | // needs initialization |
| 138 | } |
| 139 | else if (var.getTypeName() == "std::array") { |
| 140 | const Token* ctt = var.valueType()->containerTypeToken; |
| 141 | if (!ctt->isStandardType() && |
| 142 | (!ctt->type() || ctt->type()->needInitialization != Type::NeedInitialization::True) && |
| 143 | !mSettings.library.podtype(ctt->str())) // TODO: handle complex type expression |
| 144 | return true; |
| 145 | } |
| 146 | else |
| 147 | return true; |
| 148 | } |
| 149 | else |
| 150 | return true; |
| 151 | } |
| 152 | |
| 153 | // Known type that doesn't need initialization or |
| 154 | // known type that has member variables of an unknown type |
| 155 | else if (var.type()->needInitialization != Type::NeedInitialization::True) |
| 156 | return true; |
| 157 | } |
| 158 | |
| 159 | // Check if type can't be copied |
| 160 | if (!var.isPointer() && !var.isPointerArray() && var.typeScope()) { |
| 161 | if (funcType == FunctionType::eMoveConstructor) { |
| 162 | if (canNotMove(var.typeScope())) |
| 163 | return true; |
| 164 | } |
| 165 | else { |
| 166 | if (canNotCopy(var.typeScope())) |
| 167 | return true; |
| 168 | } |
| 169 | } |
| 170 | return false; |
| 171 | } |
nothing calls this directly
no test coverage detected