| 2561 | } |
| 2562 | |
| 2563 | void TestDUChain::testSizeAlignOfUpdate() |
| 2564 | { |
| 2565 | TestFile file(QStringLiteral(R"( |
| 2566 | struct foo { int i; }; |
| 2567 | )"), |
| 2568 | QStringLiteral("cpp")); |
| 2569 | file.parse(TopDUContext::AllDeclarationsContextsAndUses); |
| 2570 | QVERIFY(file.waitForParsed(1000)); |
| 2571 | |
| 2572 | { |
| 2573 | DUChainReadLocker lock; |
| 2574 | const auto top = file.topContext(); |
| 2575 | QVERIFY(top); |
| 2576 | QVERIFY(top->problems().isEmpty()); |
| 2577 | QCOMPARE(top->localDeclarations().size(), 1); |
| 2578 | const auto type = top->localDeclarations().constFirst()->abstractType(); |
| 2579 | QCOMPARE(type->sizeOf(), 4); |
| 2580 | QCOMPARE(type->alignOf(), 4); |
| 2581 | } |
| 2582 | |
| 2583 | file.setFileContents(QStringLiteral(R"( |
| 2584 | struct foo { char i[124]; }; |
| 2585 | )")); |
| 2586 | file.parse(TopDUContext::AllDeclarationsContextsAndUses | TopDUContext::ForceUpdate); |
| 2587 | QVERIFY(file.waitForParsed(1000)); |
| 2588 | |
| 2589 | { |
| 2590 | DUChainReadLocker lock; |
| 2591 | const auto top = file.topContext(); |
| 2592 | QVERIFY(top); |
| 2593 | QVERIFY(top->problems().isEmpty()); |
| 2594 | QCOMPARE(top->localDeclarations().size(), 1); |
| 2595 | const auto type = top->localDeclarations().constFirst()->abstractType(); |
| 2596 | QCOMPARE(type->sizeOf(), 124); |
| 2597 | QCOMPARE(type->alignOf(), 1); |
| 2598 | } |
| 2599 | } |
| 2600 | |
| 2601 | void TestDUChain::testBitWidth() |
| 2602 | { |
nothing calls this directly
no test coverage detected