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

Method setFlags

lib/symboldatabase.cpp:2875–2932  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2873}
2874
2875const Token *Function::setFlags(const Token *tok1, const Scope *scope)
2876{
2877 if (tok1->isInline())
2878 isInlineKeyword(true);
2879
2880 if (tok1->isExternC())
2881 isExtern(true);
2882
2883 // look for end of previous statement
2884 while (tok1->previous() && !Token::Match(tok1->previous(), ";|}|{|public:|protected:|private:")) {
2885 tok1 = tok1->previous();
2886
2887 if (tok1->isInline())
2888 isInlineKeyword(true);
2889
2890 // extern function
2891 if (tok1->str() == "extern") {
2892 isExtern(true);
2893 }
2894
2895 // virtual function
2896 else if (tok1->str() == "virtual") {
2897 hasVirtualSpecifier(true);
2898 }
2899
2900 // static function
2901 else if (tok1->str() == "static") {
2902 isStatic(true);
2903 if (scope->type == ScopeType::eNamespace || scope->type == ScopeType::eGlobal)
2904 isStaticLocal(true);
2905 }
2906
2907 // friend function
2908 else if (tok1->str() == "friend") {
2909 isFriend(true);
2910 }
2911
2912 // constexpr function
2913 else if (tok1->str() == "constexpr") {
2914 isConstexpr(true);
2915 }
2916
2917 // decltype
2918 else if (tok1->str() == ")" && Token::simpleMatch(tok1->link()->previous(), "decltype (")) {
2919 tok1 = tok1->link()->previous();
2920 }
2921
2922 else if (tok1->link() && tok1->str() == ">") {
2923 // Function template
2924 if (Token::simpleMatch(tok1->link()->previous(), "template <")) {
2925 templateDef = tok1->link()->previous();
2926 break;
2927 }
2928 tok1 = tok1->link();
2929 }
2930 }
2931 return tok1;
2932}

Callers 5

ProjectFileDialogMethod · 0.80
addIncludeDirMethod · 0.80
addCheckPathMethod · 0.80
addExcludePathMethod · 0.80

Calls 9

isInlineKeywordFunction · 0.85
isExternFunction · 0.85
hasVirtualSpecifierFunction · 0.85
isStaticFunction · 0.85
isStaticLocalFunction · 0.85
isFriendFunction · 0.85
isConstexprFunction · 0.70
simpleMatchFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected