This is an archive of the discontinued LLVM Phabricator instance.

PR23175 (unit test) - Infinite loop iterating Objective-C method declarations in categories when the AST was deserialized from an .ast file
Needs ReviewPublic

Authored by tahonermann on Apr 20 2015, 1:59 PM.

Details

Reviewers
klimek
Summary

This patch adds a unit test demonstrating an error in Objective-C method declaration enumeration that occurs when an AST is deserialized from an .ast file.

A few notes about the unit test:

  1. The patch was produced based on r234313.
  2. This adds a new unittests/Serialization directory and unit test to exercise AST matching on an AST that has been serialized and deserialized.
  3. I'm not proficient with the AST matchers. There may be a better way to handle this. I added a declarationCountIs() AST matcher at one point, but I lacked convenient infrastructure like that available in unittests/ASTMatchers to validate the matches.
  4. This adds an additional parameter with default argument to buildASTFromCode() and buildASTFromCodeWithArgs() that is used to indicate whether the code should be serialized and deserialized prior to returning the AST.

The test currently fails, but without going into an infinite loop (iteration is terminated if more than the expected number of declarations are enumerated). Passing 'true' for 'Reserialize' to buildASTFromCode() in the new test suffices to make the test pass, thus demonstrating that the issue is related to AST serialization and deserialization.

Diff Detail

Repository
rL LLVM

Event Timeline

tahonermann retitled this revision from to PR23175 (unit test) - Infinite loop iterating Objective-C method declarations in categories when the AST was deserialized from an .ast file.
tahonermann updated this object.
tahonermann edited the test plan for this revision. (Show Details)
tahonermann added a reviewer: klimek.
tahonermann set the repository for this revision to rL LLVM.
tahonermann added a subscriber: Unknown Object (MLST).
rsmith added a subscriber: rsmith.Apr 21 2015, 6:51 PM
rsmith added inline comments.
unittests/Serialization/Reserialization.cpp
1

I'm not completely sure what "reserialization" means here; I'd expect this to be tests for serializing stuff we'd deserialized (which we generally avoid doing). Maybe something like "Serialization/Decls.cpp" would be a better name for tests of Decl deserialization?

tahonermann added inline comments.Apr 22 2015, 8:31 AM
unittests/Serialization/Reserialization.cpp
1

You are right, this could use a better name. I'm reaching for a term that describes "produce an AST, serialize it, deserialize it, then test it". I wasn't able to come up with anything better. Perhaps a term isn't necessary in which case 'Decls.cpp' would be just fine.

klimek added inline comments.Apr 22 2015, 8:39 AM
include/clang/Tooling/Tooling.h
173

I don't think this is the right choice.
It seems like we could provide two functions serialize and deserialize so that Reserialize=true becomes
deserialize(serialize(buildASTFromCode(...))
?

tahonermann added inline comments.Apr 22 2015, 12:07 PM
include/clang/Tooling/Tooling.h
173

Ah, yes. I agree that better encapsulates separation of concerns.

klimek edited edge metadata.Jul 3 2015, 6:48 AM

What's the state of this?

What's the state of this?

I'm not sure who that question is directed to. You haven't accepted the review, so I presume you are awaiting updates, probably from me. Unfortunately, my time is very limited.