This is an archive of the discontinued LLVM Phabricator instance.

[ASTImporter] Add unit tests for structural equivalence
ClosedPublic

Authored by martong on May 15 2018, 3:28 AM.

Details

Summary

This patch add new tests for structural equivalence. For that a new common header is created which holds the test related language specific types and functions.

Diff Detail

Repository
rC Clang

Event Timeline

martong created this revision.May 15 2018, 3:28 AM

Hello Gabor!

Thank you for this patch! Do you plan to enable this functionality for AST import checking?
Some comments are inline.

unittests/AST/Language.h
2

Header line is too short.

9

Could you please add a brief file description?

14

System includes should follow LLVM includes.

38

I think this function is too big for a header. Same below. Could you create a source file?

unittests/AST/StructuralEquivalenceTest.cpp
3

Do we need ASTImporter.h?

40

s/Import/Search?

48

Nit: comments should end with dot. Could you please check?

49

Can we assert(FoundDecls.size() == 1)?

55

D0, D1 (capital). Same below.

74

Could we just overload testStructuralMatch to accept tuple or pair?

120

Should we assert for spec_begin() != spec_end() instead or within these assertions?

164

There is no Code1, so I think we can call it just "Code". Same below.

175
  1. It's better to use more meaningful names than t. DeclTuple?
  2. The space after ( is redundant.
194

Redundant space. Could you clang-format?

196

These assertions are always true because there is a strong C assertion in the callee.

martong marked 14 inline comments as done.May 17 2018, 6:20 AM

Do you plan to enable this functionality for AST import checking?

Yes. We'd like to test the structural equivalency independently from ASTImporter, because in certain cases it may have faulty behavior. This can be very handy also when we further extend structural equivalency.

unittests/AST/StructuralEquivalenceTest.cpp
120

I think that is not needed, because the previous cast in line 116 and 118 would assert if spec_begin() == spec_end() was true.

175

Renamed t to Decls.

martong updated this revision to Diff 147304.May 17 2018, 6:21 AM
martong marked an inline comment as done.
  • Address aleksei's comments
a.sidorin accepted this revision.May 23 2018, 10:39 AM

Hi Gabor,

LGTM, thank you for addressing the comments! Just a minor nit, it's OK to fix it before committing without a separate review.

unittests/AST/StructuralEquivalenceTest.cpp
68

Not sure we need this using: we can move up the using below or just write std::get twice.

This revision is now accepted and ready to land.May 23 2018, 10:39 AM
martong updated this revision to Diff 148352.May 24 2018, 1:42 AM

Moved using std::get up, before testStructuralMatch.

martong marked an inline comment as done.May 24 2018, 1:43 AM
This revision was automatically updated to reflect the committed changes.