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

Function scopesMatch

lib/tokenize.cpp:2881–2906  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2879}
2880
2881static bool scopesMatch(const std::string &scope1, const std::string &scope2, const ScopeInfo3 *globalScope)
2882{
2883 if (scope1.empty() || scope2.empty())
2884 return false;
2885
2886 // check if scopes match
2887 if (scope1 == scope2)
2888 return true;
2889
2890 // check if scopes only differ by global qualification
2891 if (scope1 == (":: " + scope2)) {
2892 std::string::size_type end = scope2.find_first_of(' ');
2893 if (end == std::string::npos)
2894 end = scope2.size();
2895 if (globalScope->hasChild(scope2.substr(0, end)))
2896 return true;
2897 } else if (scope2 == (":: " + scope1)) {
2898 std::string::size_type end = scope1.find_first_of(' ');
2899 if (end == std::string::npos)
2900 end = scope1.size();
2901 if (globalScope->hasChild(scope1.substr(0, end)))
2902 return true;
2903 }
2904
2905 return false;
2906}
2907
2908static unsigned int tokDistance(const Token* tok1, const Token* tok2) { // use when index() is not available yet
2909 unsigned int dist = 0;

Callers 1

simplifyUsingMethod · 0.85

Calls 3

hasChildMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected