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

Method initBaseInfo

lib/symboldatabase.cpp:3742–3824  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3740}
3741
3742const Token *Type::initBaseInfo(const Token *tok, const Token *tok1)
3743{
3744 // goto initial '{'
3745 const Token *tok2 = tok1;
3746 while (tok2 && tok2->str() != "{") {
3747 // skip unsupported templates
3748 if (tok2->str() == "<")
3749 tok2 = tok2->link();
3750
3751 // check for base classes
3752 else if (Token::Match(tok2, ":|,")) {
3753 tok2 = tok2->next();
3754
3755 // check for invalid code
3756 if (!tok2 || !tok2->next())
3757 return nullptr;
3758
3759 Type::BaseInfo base;
3760
3761 if (tok2->str() == "virtual") {
3762 base.isVirtual = true;
3763 tok2 = tok2->next();
3764 }
3765
3766 if (tok2->str() == "public") {
3767 base.access = AccessControl::Public;
3768 tok2 = tok2->next();
3769 } else if (tok2->str() == "protected") {
3770 base.access = AccessControl::Protected;
3771 tok2 = tok2->next();
3772 } else if (tok2->str() == "private") {
3773 base.access = AccessControl::Private;
3774 tok2 = tok2->next();
3775 } else {
3776 if (tok->str() == "class")
3777 base.access = AccessControl::Private;
3778 else if (tok->str() == "struct")
3779 base.access = AccessControl::Public;
3780 }
3781 if (!tok2)
3782 return nullptr;
3783 if (tok2->str() == "virtual") {
3784 base.isVirtual = true;
3785 tok2 = tok2->next();
3786 }
3787 if (!tok2)
3788 return nullptr;
3789
3790 base.nameTok = tok2;
3791 // handle global namespace
3792 if (tok2->str() == "::") {
3793 tok2 = tok2->next();
3794 }
3795
3796 // handle derived base classes
3797 while (Token::Match(tok2, "%name% ::")) {
3798 tok2 = tok2->tokAt(2);
3799 }

Callers 1

Calls 6

nextMethod · 0.80
findTypeMethod · 0.80
findDependencyMethod · 0.80
strMethod · 0.45
tokAtMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected