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

Function getConstFunctions

lib/checkother.cpp:2836–2854  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2834 }
2835
2836 void getConstFunctions(const SymbolDatabase *symbolDatabase, std::list<const Function*> &constFunctions)
2837 {
2838 for (const Scope &scope : symbolDatabase->scopeList) {
2839 // only add const functions that do not have a non-const overloaded version
2840 // since it is pretty much impossible to tell which is being called.
2841 using StringFunctionMap = std::map<std::string, std::list<const Function*>>;
2842 StringFunctionMap functionsByName;
2843 for (const Function &func : scope.functionList) {
2844 functionsByName[func.tokenDef->str()].push_back(&func);
2845 }
2846 for (std::pair<const std::string, std::list<const Function*>>& it : functionsByName) {
2847 const auto nc = std::find_if(it.second.cbegin(), it.second.cend(), notconst);
2848 if (nc == it.second.cend()) {
2849 // ok to add all of them
2850 constFunctions.splice(constFunctions.end(), it.second);
2851 }
2852 }
2853 }
2854 }
2855}
2856
2857static bool

Callers 1

Calls 3

push_backMethod · 0.45
strMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected