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

Function findTypeImpl

lib/symboldatabase.cpp:6516–6538  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6514
6515template<class S, class T, REQUIRES("S must be a Scope class", std::is_convertible<S*, const Scope*> ), REQUIRES("T must be a Type class", std::is_convertible<T*, const Type*> )>
6516static T* findTypeImpl(S& thisScope, const std::string & name)
6517{
6518 auto it = thisScope.definedTypesMap.find(name);
6519
6520 // Type was found
6521 if (thisScope.definedTypesMap.end() != it)
6522 return it->second;
6523
6524 // is type defined in anonymous namespace..
6525 it = thisScope.definedTypesMap.find("");
6526 if (it != thisScope.definedTypesMap.end()) {
6527 for (S *scope : thisScope.nestedList) {
6528 if (scope->className.empty() && (scope->type == ScopeType::eNamespace || scope->isClassOrStructOrUnion())) {
6529 T *t = scope->findType(name);
6530 if (t)
6531 return t;
6532 }
6533 }
6534 }
6535
6536 // Type was not found
6537 return nullptr;
6538}
6539
6540const Type* Scope::findType(const std::string& name) const
6541{

Callers

nothing calls this directly

Calls 4

findTypeMethod · 0.80
findMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected