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

Method valueFlow2

test/testclangimport.cpp:1286–1302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1284 }
1285
1286 void valueFlow2() {
1287 // int buf[42];
1288 // int x = sizeof(buf);
1289 const char clang[] = "|-VarDecl 0x10f6de8 <66.cpp:3:1, col:11> col:5 referenced buf 'int [42]'\n"
1290 "`-VarDecl 0x10f6eb0 <line:4:1, col:19> col:5 x 'int' cinit\n"
1291 " `-ImplicitCastExpr 0x10f6f78 <col:9, col:19> 'int' <IntegralCast>\n"
1292 " `-UnaryExprOrTypeTraitExpr 0x10f6f58 <col:9, col:19> 'unsigned long' sizeof\n"
1293 " `-ParenExpr 0x10f6f38 <col:15, col:19> 'int [42]' lvalue\n"
1294 " `-DeclRefExpr 0x10f6f18 <col:16> 'int [42]' lvalue Var 0x10f6de8 'buf' 'int [42]' non_odr_use_unevaluated";
1295
1296 GET_SYMBOL_DB(clang);
1297
1298 const Token *tok = Token::findsimplematch(tokenizer.tokens(), "sizeof (");
1299 ASSERT(!!tok);
1300 tok = tok->next();
1301 TODO_ASSERT_EQUALS(true, false, tok->hasKnownIntValue() && tok->getKnownIntValue() == 10);
1302 }
1303
1304 void valueType1() {
1305 const char clang[] = "`-FunctionDecl 0x32438c0 <a.cpp:5:1, line:7:1> line:5:6 foo 'a::b (a::b)'\n"

Callers

nothing calls this directly

Calls 4

findsimplematchFunction · 0.85
nextMethod · 0.80
getKnownIntValueMethod · 0.80
hasKnownIntValueMethod · 0.45

Tested by

no test coverage detected