| 1068 | } |
| 1069 | |
| 1070 | static const ValueFlow::Value* getInnerLifetime(const Token* tok, |
| 1071 | nonneg int id, |
| 1072 | ErrorPath* errorPath = nullptr, |
| 1073 | int depth = 4) |
| 1074 | { |
| 1075 | if (depth < 0) |
| 1076 | return nullptr; |
| 1077 | if (!tok) |
| 1078 | return nullptr; |
| 1079 | for (const ValueFlow::Value& val : tok->values()) { |
| 1080 | if (!val.isLocalLifetimeValue()) |
| 1081 | continue; |
| 1082 | if (contains({ValueFlow::Value::LifetimeKind::Address, |
| 1083 | ValueFlow::Value::LifetimeKind::SubObject, |
| 1084 | ValueFlow::Value::LifetimeKind::Lambda}, |
| 1085 | val.lifetimeKind)) { |
| 1086 | if (val.isInconclusive()) |
| 1087 | return nullptr; |
| 1088 | if (val.capturetok) |
| 1089 | if (const ValueFlow::Value* v = getInnerLifetime(val.capturetok, id, errorPath, depth - 1)) |
| 1090 | return v; |
| 1091 | if (errorPath) |
| 1092 | errorPath->insert(errorPath->end(), val.errorPath.cbegin(), val.errorPath.cend()); |
| 1093 | if (const ValueFlow::Value* v = getInnerLifetime(val.tokvalue, id, errorPath, depth - 1)) |
| 1094 | return v; |
| 1095 | continue; |
| 1096 | } |
| 1097 | if (!val.tokvalue->variable()) |
| 1098 | continue; |
| 1099 | if (val.tokvalue->varId() != id) |
| 1100 | continue; |
| 1101 | return &val; |
| 1102 | } |
| 1103 | return nullptr; |
| 1104 | } |
| 1105 | |
| 1106 | static const Token* endOfExpression(const Token* tok) |
| 1107 | { |
no test coverage detected