Page MenuHomePhabricator

Add support for injected class names and constructor initializers in C++
AbandonedPublic

Authored by a.sidorin on May 10 2016, 11:02 AM.

Details

Reviewers
sepavloff
spyffe
Summary

The AST importer currently does not handle injected class names properly (it does not bind their types to the type of the parent as the parser would) and it doesn't handle constructor initializers at all.

This patch adds support for both of those, and also forwards the isImplicit() and isReferenced() flags for *all* declarations as is done for isUsed().

Diff Detail

Repository
rL LLVM

Event Timeline

spyffe updated this revision to Diff 56754.May 10 2016, 11:02 AM
spyffe retitled this revision from to Add support for injected class names and constructor initializers in C++.
spyffe updated this object.
spyffe added reviewers: sepavloff, a.sidorin.
spyffe set the repository for this revision to rL LLVM.
spyffe added a project: Restricted Project.
spyffe added a subscriber: cfe-commits.
a.sidorin edited edge metadata.May 11 2016, 4:39 AM

I' d like to have some tests for this. CXXCtorInitializers can be tested with D14224-like stuff or with ASTMatchers (ASTImporterTest.cpp).
Some code samples may be found in CXX/Sema tests, you just need to port/simplify them.

lib/AST/ASTImporter.cpp
3034

In my latest patch, I have introduced a function named ImportContainerChecked(). I think it could make this code a bit more clean. What do you think?

3035

Space after '='

3041

If we move this condition (I suggest to use FromConstructor->getNumCtorIintializers() instead) upper to cover the importing loop, we may skip this loop as well.

3045

As I can see, LLVM code style avoids qualified casts.

6384

Trailing whitespace.

6389

The indentation for ?: here is a bit confusing.

6396

Training whitespace. It's pretty difficult to find them with Phabricator, could you check your patch for them?

6423

It seems like a case with indexed initializer is missed here. You can find my implementation on https://github.com/haoNoQ/clang/blob/summary-ipa-draft/lib/AST/ASTImporter.cpp#L2456-L2464.
A sample that requires it is auto parens4 = [p4(1)] {}; (test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp)

spyffe added a subscriber: spyffe.May 13 2016, 1:40 PM

Thank you for your comments, I’m working on them now.

Sean

I’m just going to use clang-format to resolve trailing whitespace/etc issues. It changes around some indentation in the class declaration for ASTImporter but that probably needs to be taken care of anyway…

Sean

a.sidorin commandeered this revision.May 29 2018, 7:19 AM
a.sidorin edited reviewers, added: spyffe; removed: a.sidorin.
a.sidorin abandoned this revision.May 29 2018, 7:24 AM

This revision seems to be already committed in rC269693, without Differential Revision set.