This is an archive of the discontinued LLVM Phabricator instance.

[SyntaxTree] Create annotations infrastructure and apply it in expression tests.
ClosedPublic

Authored by eduucaldas on Aug 14 2020, 2:58 AM.

Details

Summary

In this process we also create some other tests, in order to not lose
coverage when focusing on the annotated code.

Diff Detail

Event Timeline

eduucaldas created this revision.Aug 14 2020, 2:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2020, 2:58 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
eduucaldas requested review of this revision.Aug 14 2020, 2:58 AM
eduucaldas updated this revision to Diff 285613.

Previous diff had only the last commit

Move added Declaration tests to an appropriate place

Add annotations to the last missing tests in expressions.

gribozavr2 added inline comments.Aug 14 2020, 5:32 AM
clang/unittests/Tooling/Syntax/TreeTestBase.cpp
197
199

ASSERT_EQ I think would be better.

200

LLVM style is usually:

unsigned i = 0; ...

206

Could you dump the annotated source code substring to make debugging failing tests easier?

gribozavr2 accepted this revision.Aug 14 2020, 3:03 PM

Very nice improvement to tests!

clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
909

The name of this test should be about declarations, and this test should be in the section of this file that has to do with declarations.

1160

The name of this test should be only about typedefs, and not about user-defined literals. The test should be also in the section of this file that is about declarations (down below).

2642

I think it should be T var, otherwise T is not used (not using T is valid, but rather unusual).

This revision is now accepted and ready to land.Aug 14 2020, 3:03 PM
eduucaldas marked 7 inline comments as done.

Answering comments

clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
477

A test for this part was created below

clang/unittests/Tooling/Syntax/TreeTestBase.cpp
199

ASSERT_EQ is a macro that returns void, so we cannot use it here.

However that brings another question.
Right now we have methods treeDumpEqual* that return AssertionResults and we use them in our tests in the following way: EXPECT_TRUE(treeDumpEqual*...).
It seems to me that we should instead perform any assertion inside treeDumpEqual*, and then just call it directly in the test.

WDYT? I case you agree we can perform this change in another patch.

206

Very good suggestion :) thanks

Fail on non-matching number of tree dumps and annotations

clang/unittests/Tooling/Syntax/TreeTestBase.cpp
199

We need the EXPECT_TRUE at the test site to get information about in which line number we failed

This revision was landed with ongoing or failed builds.Aug 18 2020, 6:01 AM
This revision was automatically updated to reflect the committed changes.