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

Method simplifyExternC

lib/tokenize.cpp:3743–3767  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3741}
3742
3743void Tokenizer::simplifyExternC()
3744{
3745 if (isC())
3746 return;
3747
3748 // Add attributes to all tokens within `extern "C"` inlines and blocks, and remove the `extern "C"` tokens.
3749 for (Token *tok = list.front(); tok; tok = tok->next()) {
3750 if (Token::Match(tok, "extern \"C\"|\"C++\"")) {
3751 Token *tok2 = tok->next();
3752 const bool isExtC = tok->strAt(1).size() == 3;
3753 if (tok->strAt(2) == "{") {
3754 tok2 = tok2->next(); // skip {
3755 while ((tok2 = tok2->next()) && tok2 != tok->linkAt(2))
3756 tok2->isExternC(isExtC);
3757 tok->linkAt(2)->deleteThis(); // }
3758 tok->deleteNext(2); // "C" {
3759 } else {
3760 while ((tok2 = tok2->next()) && !Token::Match(tok2, "[;{]"))
3761 tok2->isExternC(isExtC);
3762 tok->deleteNext(); // "C"
3763 }
3764 tok->deleteThis(); // extern
3765 }
3766 }
3767}
3768
3769void Tokenizer::simplifyCompoundStatements()
3770{

Callers

nothing calls this directly

Calls 7

frontMethod · 0.80
nextMethod · 0.80
linkAtMethod · 0.80
deleteThisMethod · 0.80
deleteNextMethod · 0.80
isCFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected