This is an archive of the discontinued LLVM Phabricator instance.

[ASTImporter][NFC] Improve test coverage
ClosedPublic

Authored by steakhal on Mar 30 2021, 3:34 AM.

Details

Summary

All three cases were imported correctly.
For BlockDecls, correctly means that we don't support importing them, thus an error is the expected behaviour.

  • BlockDecls were not yet covered. I know that they are not imported but the test at least documents it.
  • Default values for ParmVarDecls were also uncovered.
  • Importing bitfield FieldDecls were imported correctly.

Diff Detail

Event Timeline

steakhal created this revision.Mar 30 2021, 3:34 AM
steakhal requested review of this revision.Mar 30 2021, 3:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 30 2021, 3:34 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
martong accepted this revision.Mar 30 2021, 8:14 AM

LGTM! Thanks!

This revision is now accepted and ready to land.Mar 30 2021, 8:14 AM
shafik accepted this revision.Mar 30 2021, 10:03 AM

Thank you for adding these tests! LGTM

clang/unittests/AST/ASTImporterTest.cpp
3078

Can we also check they type of the bitfield?

This revision was landed with ongoing or failed builds.Mar 31 2021, 3:11 AM
This revision was automatically updated to reflect the committed changes.
thakis added a subscriber: thakis.Mar 31 2021, 3:25 AM
thakis added inline comments.
clang/unittests/AST/ASTImporterTest.cpp
3089

Does this have to be a global? It can just be in the TEST_P, no?

As-is, this causes linker errors: http://45.33.8.238/linux/43089/step_4.txt

If it does have to be a global for some reason, please put it in an unnamed namespace.

steakhal added inline comments.Mar 31 2021, 3:28 AM
clang/unittests/AST/ASTImporterTest.cpp
3089

Hmm I don't know. I was just copy-pasting from for example line 515.

const internal::VariadicDynCastAllOfMatcher<Expr, VAArgExpr> vaArgExpr;

How is my case different from that?
I thought it's the way of doing this.

thakis added inline comments.Mar 31 2021, 3:39 AM
clang/unittests/AST/ASTImporterTest.cpp
3089

I think the vaArgExpr on line 515 could be local to the ImportVAArgExpr test too.

What's different with your test is that ASTMatchersInternal.cpp already has a global symbol called blockDecl, leading to a duplicate symbol error.

…actually I guess you could just use that one? I think you can just delete the blockDecl line completely and things will probably be fine.

steakhal marked 2 inline comments as done.Mar 31 2021, 3:49 AM
steakhal added inline comments.
clang/unittests/AST/ASTImporterTest.cpp
3089

I pushed the change. I hope it fixes the issue.
I don't know how I missed it. Thanks for the heads up.

steakhal marked an inline comment as done.Mar 31 2021, 3:51 AM
steakhal added inline comments.
clang/unittests/AST/ASTImporterTest.cpp
3089

@thakis How did the premerge test pass then?
That supposed to catch build bot issues before the revision lands, am I right?

Thanks, that bot is happy again.

clang/unittests/AST/ASTImporterTest.cpp
3089

It probably only tests on config. Might depend on if dead code stripping is enabled (?)