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

Method isKeyword

lib/tokenlist.cpp:2293–2318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2291}
2292
2293bool TokenList::isKeyword(const std::string &str) const
2294{
2295 if (isCPP()) {
2296 const auto &cpp_keywords = Keywords::getAll(mSettings.standards.cpp);
2297 const bool b = cpp_keywords.find(str) != cpp_keywords.end();
2298 if (b) {
2299 // TODO: integrate into keywords?
2300 // types and literals are not handled as keywords
2301 static const std::unordered_set<std::string> cpp_types = {"bool", "false", "true"};
2302 if (cpp_types.find(str) != cpp_types.end())
2303 return false;
2304 }
2305 return b;
2306 }
2307
2308 const auto &c_keywords = Keywords::getAll(mSettings.standards.c);
2309 const bool b = c_keywords.find(str) != c_keywords.end();
2310 if (b) {
2311 // TODO: integrate into Keywords?
2312 // types are not handled as keywords
2313 static const std::unordered_set<std::string> c_types = {"char", "double", "float", "int", "long", "short"};
2314 if (c_types.find(str) != c_types.end())
2315 return false;
2316 }
2317 return b;
2318}
2319
2320bool TokenList::isC() const
2321{

Callers 15

negativeArraySizeMethod · 0.45
isScopeNoReturnMethod · 0.45
isNotLibraryFunctionMethod · 0.45
detectSmartPointerMethod · 0.45
getAllocationTypeMethod · 0.45
variableMethod · 0.45
checkStructVariableMethod · 0.45
iscpp11init_implFunction · 0.45
isPrefixUnaryFunction · 0.45
compilePrecedence2Function · 0.45

Calls 3

isCPPFunction · 0.85
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected