Page MenuHomePhabricator

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

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



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


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.


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?


Space after '='


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.


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


Trailing whitespace.


The indentation for ?: here is a bit confusing.


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


It seems like a case with indexed initializer is missed here. You can find my implementation on
A sample that requires it is auto parens4 = [p4(1)] {}; (test/CXX/dcl.dcl/dcl.spec/dcl.type/

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

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


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…


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.