As a type, this can be visited upon. This is similar in spirit to the
BlockDecl::Capture type.
Details
- Reviewers
aaron.ballman riccibruno
Diff Detail
- Repository
- rC Clang
- Build Status
Buildable 27094 Build 27093: arc lint + arc unit
Event Timeline
include/clang/AST/Expr.h | ||
---|---|---|
5068 | Rather than gin these objects up on demand every time they're needed, I'd prefer to see the class store Association objects directly. I don't think it will be easy to do that and still support getAssocExprs() and getAssocTypeSourceInfos(), so I think those APIs should be removed in favor of this one. There's currently not many uses of getAssocExprs() or getAssocTypeSourceInfos() (I spot one each in Clang) so migration to the new API should not be onerous. This should also have a range-based accessor version so that users aren't required to use iterative loops to access the information (a lot of the places you're already touching could use that range-based interface). | |
lib/AST/ASTDumper.cpp | ||
1467 | Don't use auto here. | |
lib/AST/StmtPrinter.cpp | ||
1266 | Don't use auto. | |
lib/AST/StmtProfile.cpp | ||
1263 | Or here (or anywhere similar in this patch; I'll stop commenting on them). |
include/clang/AST/Expr.h | ||
---|---|---|
5068 | I would prefer that too, but it doesn't seem to be possible. This is a sub-range of the SubExprs returned from children(). In theory, that could be split into two members, but then you would need a range library to recombine them and implement children(): https://godbolt.org/z/ZVamdC This seems to be the best approach for now, and AFAIK it excludes a range-accessor. |
include/clang/AST/Expr.h | ||
---|---|---|
5068 |
Ugh, you're right. :-(
We have zip iterators that could be used to implement this, I believe. (see STLExtras.h) Alternatively, we could tail-allocate the Association objects with (perhaps references to) pointers back into the Expr tail-allocated array. Not ideal, but does provide a clean interface. @riccibruno may have other ideas on how to pack the arrays, as he's done a lot of this work recently. |
include/clang/AST/Expr.h | ||
---|---|---|
5068 |
You're right, there is a concat there, but on second thought - because Association and Stmt don't share a base, I don't think it can work.
Perhaps this can work, but I don't know how to do it. If you have scope for it in your part of the efforts, it would be a good way to get this unblocked. |
include/clang/AST/Expr.h | ||
---|---|---|
5068 |
I'll put some time into it today and see where it goes. You may be right that this is more work than it's worth, so we'll see. |
include/clang/AST/Expr.h | ||
---|---|---|
5068 | I don't see what would prevent tail-allocating the array of sub-expression and the array of TypeSourceInfo, and removing the getAssocExpr, getAssocTypeSourceInfo, getAssocType interface in favor of a single getAssociation. Then create a range version of getAssociation using the fact that if you know where you are in the sub-expression array, you know where is the corresponding TypeSourceInfo. To know which index correspond to the selected sub-expression you could use one of the low bits in the TypeSourceInfo pointers. This means that children is still simple to implement, and users can use a single unified |
I know that this is not part of this patch, but these arrays are begging
to be tail-allocated if you want to have a go at it.