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

Function gotoEndIf

lib/preprocessor.cpp:582–597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

580}
581
582static const simplecpp::Token *gotoEndIf(const simplecpp::Token *cmdtok)
583{
584 int level = 0;
585 while (nullptr != (cmdtok = cmdtok->next)) {
586 if (cmdtok->op == '#' && !sameline(cmdtok->previous,cmdtok) && sameline(cmdtok, cmdtok->next)) {
587 if (startsWith(cmdtok->next->str(),"if"))
588 ++level;
589 else if (cmdtok->next->str() == "endif") {
590 --level;
591 if (level < 0)
592 return cmdtok;
593 }
594 }
595 }
596 return nullptr;
597}
598
599static void getConfigs(const simplecpp::TokenList &tokens, std::set<std::string> &defined, const std::string &userDefines, const std::set<std::string> &undefined, std::set<std::string> &ret)
600{

Callers 1

getConfigsFunction · 0.85

Calls 3

samelineFunction · 0.70
startsWithFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected