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

Method functionArgs20

test/testsymboldatabase.cpp:3024–3060  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3022 }
3023
3024 void functionArgs20() {
3025 {
3026 const char code[] = "void f(void *(*g)(void *) = [](void *p) { return p; }) {}"; // #11769
3027 GET_SYMBOL_DB(code);
3028 ASSERT(db != nullptr);
3029 const Scope *scope = db->functionScopes.front();
3030 const Function *func = scope->function;
3031 ASSERT_EQUALS(1, func->argCount());
3032 const Variable* arg = func->getArgumentVar(0);
3033 TODO_ASSERT(arg->hasDefault());
3034 }
3035 {
3036 const char code[] = "void f() { auto g = [&](const std::function<int(int)>& h = [](int i) -> int { return i; }) {}; }"; // #12338
3037 GET_SYMBOL_DB(code);
3038 ASSERT(db != nullptr);
3039 ASSERT_EQUALS(3, db->scopeList.size());
3040 ASSERT_EQUALS_ENUM(ScopeType::eLambda, db->scopeList.back().type);
3041 }
3042 {
3043 const char code[] = "void f() {\n"
3044 " auto g = [&](const std::function<const std::vector<int>&(const std::vector<int>&)>& h = [](const std::vector<int>& v) -> const std::vector<int>& { return v; }) {};\n"
3045 "}\n";
3046 GET_SYMBOL_DB(code);
3047 ASSERT(db != nullptr);
3048 ASSERT_EQUALS(3, db->scopeList.size());
3049 ASSERT_EQUALS_ENUM(ScopeType::eLambda, db->scopeList.back().type);
3050 }
3051 {
3052 const char code[] = "void f() {\n"
3053 " auto g = [&](const std::function<int(int)>& h = [](int i) -> decltype(0) { return i; }) {};\n"
3054 "}\n";
3055 GET_SYMBOL_DB(code);
3056 ASSERT(db != nullptr);
3057 ASSERT_EQUALS(3, db->scopeList.size());
3058 ASSERT_EQUALS_ENUM(ScopeType::eLambda, db->scopeList.back().type);
3059 }
3060 }
3061
3062 void functionArgs21() {
3063 const char code[] = "void f(std::vector<int>::size_type) {}\n" // #11408

Callers

nothing calls this directly

Calls 3

frontMethod · 0.80
getArgumentVarMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected