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

Method valueFlow1

test/testclangimport.cpp:1269–1284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1267 }
1268
1269 void valueFlow1() {
1270 // struct S { int x; int buf[10]; } ; int sz = sizeof(struct S);
1271 const char clang[] = "|-RecordDecl 0x2fc5a88 <1.c:1:1, line:4:1> line:1:8 struct S definition\n"
1272 "| |-FieldDecl 0x2fc5b48 <line:2:3, col:7> col:7 x 'int'\n"
1273 "| `-FieldDecl 0x2fc5c10 <line:3:3, col:13> col:7 buf 'int [10]'\n"
1274 "`-VarDecl 0x2fc5c70 <line:6:1, col:25> col:5 sz 'int' cinit\n"
1275 " `-ImplicitCastExpr 0x2fc5d88 <col:10, col:25> 'int' <IntegralCast>\n"
1276 " `-UnaryExprOrTypeTraitExpr 0x2fc5d68 <col:10, col:25> 'unsigned long' sizeof 'struct S':'struct S'";
1277 GET_SYMBOL_DB(clang);
1278
1279 const Token *tok = Token::findsimplematch(tokenizer.tokens(), "sizeof (");
1280 ASSERT(!!tok);
1281 tok = tok->next();
1282 ASSERT(tok->hasKnownIntValue());
1283 ASSERT_EQUALS(MathLib::bigint(44), tok->getKnownIntValue());
1284 }
1285
1286 void valueFlow2() {
1287 // int buf[42];

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