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

Method functionArgs7

test/testsymboldatabase.cpp:2769–2830  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2767 }
2768
2769 void functionArgs7() { // #7652
2770 {
2771 GET_SYMBOL_DB("struct AB { int a; int b; };\n"
2772 "int foo(struct AB *ab);\n"
2773 "void bar() {\n"
2774 " struct AB ab;\n"
2775 " foo(&ab);\n"
2776 "};");
2777 ASSERT_EQUALS(true, db != nullptr);
2778 const Token *f = Token::findsimplematch(tokenizer.tokens(), "foo ( & ab");
2779 ASSERT_EQUALS(true, f && f->function());
2780 const Function *func = f->function();
2781 ASSERT_EQUALS(true, func->tokenDef->linenr() == 2 && func->argumentList.size() == 1 && func->argumentList.front().type());
2782 const Type * type = func->argumentList.front().type();
2783 ASSERT_EQUALS(true, type->classDef->linenr() == 1);
2784 }
2785 {
2786 GET_SYMBOL_DB("struct AB { int a; int b; };\n"
2787 "int foo(AB *ab);\n"
2788 "void bar() {\n"
2789 " struct AB ab;\n"
2790 " foo(&ab);\n"
2791 "};");
2792 ASSERT_EQUALS(true, db != nullptr);
2793 const Token *f = Token::findsimplematch(tokenizer.tokens(), "foo ( & ab");
2794 ASSERT_EQUALS(true, f && f->function());
2795 const Function *func = f->function();
2796 ASSERT_EQUALS(true, func->tokenDef->linenr() == 2 && func->argumentList.size() == 1 && func->argumentList.front().type());
2797 const Type * type = func->argumentList.front().type();
2798 ASSERT_EQUALS(true, type->classDef->linenr() == 1);
2799 }
2800 {
2801 GET_SYMBOL_DB("struct AB { int a; int b; };\n"
2802 "int foo(struct AB *ab);\n"
2803 "void bar() {\n"
2804 " AB ab;\n"
2805 " foo(&ab);\n"
2806 "};");
2807 ASSERT_EQUALS(true, db != nullptr);
2808 const Token *f = Token::findsimplematch(tokenizer.tokens(), "foo ( & ab");
2809 ASSERT_EQUALS(true, f && f->function());
2810 const Function *func = f->function();
2811 ASSERT_EQUALS(true, func->tokenDef->linenr() == 2 && func->argumentList.size() == 1 && func->argumentList.front().type());
2812 const Type * type = func->argumentList.front().type();
2813 ASSERT_EQUALS(true, type->classDef->linenr() == 1);
2814 }
2815 {
2816 GET_SYMBOL_DB("struct AB { int a; int b; };\n"
2817 "int foo(AB *ab);\n"
2818 "void bar() {\n"
2819 " AB ab;\n"
2820 " foo(&ab);\n"
2821 "};");
2822 ASSERT_EQUALS(true, db != nullptr);
2823 const Token *f = Token::findsimplematch(tokenizer.tokens(), "foo ( & ab");
2824 ASSERT_EQUALS(true, f && f->function());
2825 const Function *func = f->function();
2826 ASSERT_EQUALS(true, func->tokenDef->linenr() == 2 && func->argumentList.size() == 1 && func->argumentList.front().type());

Callers

nothing calls this directly

Calls 5

findsimplematchFunction · 0.85
typeMethod · 0.80
frontMethod · 0.80
functionMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected