MCPcopy Create free account
hub / github.com/KDE/kdevelop / testSizeAlignOfUpdate

Method testSizeAlignOfUpdate

plugins/clang/tests/test_duchain.cpp:2563–2599  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2561}
2562
2563void 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
2601void TestDUChain::testBitWidth()
2602{

Callers

nothing calls this directly

Calls 11

waitForParsedMethod · 0.80
localDeclarationsMethod · 0.80
sizeOfMethod · 0.80
alignOfMethod · 0.80
parseMethod · 0.45
topContextMethod · 0.45
isEmptyMethod · 0.45
problemsMethod · 0.45
sizeMethod · 0.45
abstractTypeMethod · 0.45
setFileContentsMethod · 0.45

Tested by

no test coverage detected