| 2873 | } |
| 2874 | |
| 2875 | const 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 | } |
no test coverage detected