| 1158 | } |
| 1159 | |
| 1160 | std::string Library::getFunctionName(const Token *ftok, bool &error) const |
| 1161 | { |
| 1162 | if (!ftok) { |
| 1163 | error = true; |
| 1164 | return ""; |
| 1165 | } |
| 1166 | if (ftok->isName()) { |
| 1167 | if (Token::simpleMatch(ftok->astParent(), "::")) |
| 1168 | return ftok->str(); |
| 1169 | for (const Scope *scope = ftok->scope(); scope; scope = scope->nestedIn) { |
| 1170 | if (!scope->isClassOrStruct()) |
| 1171 | continue; |
| 1172 | const std::vector<Type::BaseInfo> &derivedFrom = scope->definedType->derivedFrom; |
| 1173 | for (const Type::BaseInfo & baseInfo : derivedFrom) { |
| 1174 | std::string name; |
| 1175 | const Token* tok = baseInfo.nameTok; // baseInfo.name still contains template parameters, but is missing namespaces |
| 1176 | if (tok->str() == "::") |
| 1177 | tok = tok->next(); |
| 1178 | while (Token::Match(tok, "%name%|::")) { |
| 1179 | name += tok->str(); |
| 1180 | tok = tok->next(); |
| 1181 | } |
| 1182 | name += "::" + ftok->str(); |
| 1183 | if (mData->mFunctions.find(name) != mData->mFunctions.end() && matchArguments(ftok, name)) |
| 1184 | return name; |
| 1185 | } |
| 1186 | } |
| 1187 | return ftok->str(); |
| 1188 | } |
| 1189 | if (ftok->str() == "::") { |
| 1190 | if (!ftok->astOperand2()) |
| 1191 | return getFunctionName(ftok->astOperand1(), error); |
| 1192 | return getFunctionName(ftok->astOperand1(),error) + "::" + getFunctionName(ftok->astOperand2(),error); |
| 1193 | } |
| 1194 | if (ftok->str() == "." && ftok->astOperand1()) { |
| 1195 | const std::string type = astCanonicalType(ftok->astOperand1(), ftok->originalName() == "->"); |
| 1196 | if (type.empty()) { |
| 1197 | error = true; |
| 1198 | return ""; |
| 1199 | } |
| 1200 | |
| 1201 | return type + "::" + getFunctionName(ftok->astOperand2(),error); |
| 1202 | } |
| 1203 | error = true; |
| 1204 | return ""; |
| 1205 | } |
| 1206 | |
| 1207 | std::string Library::getFunctionName(const Token *ftok) const |
| 1208 | { |
no test coverage detected