-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Clang][P1061] Consolidate ResolvedUnpexandedPackExpr into FunctionParmPackExpr #125394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a323e05
[Clang][P1061] Consolidate ResolvedUnexpandedPackExpr into FunctionPa…
ricejasonf 96b0096
[Clang][P1061] Remove ResolvedUnexpandedPackExpr
ricejasonf f6a77d4
[Clang][P1061] Remove unnecessary autos
ricejasonf 588dbe9
[Clang][P1061] Add test for crash
ricejasonf 3b8bece
[Clang][P1061] Use reinterpret_cast for range
ricejasonf 802e5cc
[Clang][P1061] Address nits
ricejasonf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4649,49 +4649,48 @@ class SubstNonTypeTemplateParmPackExpr : public Expr { | |
/// \endcode | ||
class FunctionParmPackExpr final | ||
: public Expr, | ||
private llvm::TrailingObjects<FunctionParmPackExpr, VarDecl *> { | ||
private llvm::TrailingObjects<FunctionParmPackExpr, ValueDecl *> { | ||
Comment on lines
4650
to
+4652
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we also update the attached comments to reflect it now supports structure binding pack? |
||
friend class ASTReader; | ||
friend class ASTStmtReader; | ||
friend TrailingObjects; | ||
|
||
/// The function parameter pack which was referenced. | ||
VarDecl *ParamPack; | ||
ValueDecl *ParamPack; | ||
|
||
/// The location of the function parameter pack reference. | ||
SourceLocation NameLoc; | ||
|
||
/// The number of expansions of this pack. | ||
unsigned NumParameters; | ||
|
||
FunctionParmPackExpr(QualType T, VarDecl *ParamPack, | ||
SourceLocation NameLoc, unsigned NumParams, | ||
VarDecl *const *Params); | ||
FunctionParmPackExpr(QualType T, ValueDecl *ParamPack, SourceLocation NameLoc, | ||
unsigned NumParams, ValueDecl *const *Params); | ||
|
||
public: | ||
static FunctionParmPackExpr *Create(const ASTContext &Context, QualType T, | ||
VarDecl *ParamPack, | ||
ValueDecl *ParamPack, | ||
SourceLocation NameLoc, | ||
ArrayRef<VarDecl *> Params); | ||
ArrayRef<ValueDecl *> Params); | ||
static FunctionParmPackExpr *CreateEmpty(const ASTContext &Context, | ||
unsigned NumParams); | ||
|
||
/// Get the parameter pack which this expression refers to. | ||
VarDecl *getParameterPack() const { return ParamPack; } | ||
ValueDecl *getParameterPack() const { return ParamPack; } | ||
|
||
/// Get the location of the parameter pack. | ||
SourceLocation getParameterPackLocation() const { return NameLoc; } | ||
|
||
/// Iterators over the parameters which the parameter pack expanded | ||
/// into. | ||
using iterator = VarDecl * const *; | ||
iterator begin() const { return getTrailingObjects<VarDecl *>(); } | ||
using iterator = ValueDecl *const *; | ||
iterator begin() const { return getTrailingObjects<ValueDecl *>(); } | ||
iterator end() const { return begin() + NumParameters; } | ||
|
||
/// Get the number of parameters in this parameter pack. | ||
unsigned getNumExpansions() const { return NumParameters; } | ||
|
||
/// Get an expansion of the parameter pack by index. | ||
VarDecl *getExpansion(unsigned I) const { return begin()[I]; } | ||
ValueDecl *getExpansion(unsigned I) const { return begin()[I]; } | ||
|
||
SourceLocation getBeginLoc() const LLVM_READONLY { return NameLoc; } | ||
SourceLocation getEndLoc() const LLVM_READONLY { return NameLoc; } | ||
|
@@ -5319,59 +5318,6 @@ class BuiltinBitCastExpr final | |
} | ||
}; | ||
|
||
// Represents an unexpanded pack where the list of expressions are | ||
// known. These are used when structured bindings introduce a pack. | ||
class ResolvedUnexpandedPackExpr final | ||
: public Expr, | ||
private llvm::TrailingObjects<ResolvedUnexpandedPackExpr, Expr *> { | ||
friend class ASTStmtReader; | ||
friend class ASTStmtWriter; | ||
friend TrailingObjects; | ||
|
||
SourceLocation BeginLoc; | ||
unsigned NumExprs; | ||
|
||
ResolvedUnexpandedPackExpr(SourceLocation BL, QualType QT, unsigned NumExprs); | ||
|
||
public: | ||
static ResolvedUnexpandedPackExpr *CreateDeserialized(ASTContext &C, | ||
unsigned NumExprs); | ||
static ResolvedUnexpandedPackExpr * | ||
Create(ASTContext &C, SourceLocation BeginLoc, QualType T, unsigned NumExprs); | ||
static ResolvedUnexpandedPackExpr *Create(ASTContext &C, | ||
SourceLocation BeginLoc, QualType T, | ||
llvm::ArrayRef<Expr *> Exprs); | ||
|
||
unsigned getNumExprs() const { return NumExprs; } | ||
|
||
llvm::MutableArrayRef<Expr *> getExprs() { | ||
return {getTrailingObjects<Expr *>(), NumExprs}; | ||
} | ||
|
||
llvm::ArrayRef<Expr *> getExprs() const { | ||
return {getTrailingObjects<Expr *>(), NumExprs}; | ||
} | ||
|
||
Expr *getExpansion(unsigned Idx) { return getExprs()[Idx]; } | ||
Expr *getExpansion(unsigned Idx) const { return getExprs()[Idx]; } | ||
|
||
// Iterators | ||
child_range children() { | ||
return child_range((Stmt **)getTrailingObjects<Expr *>(), | ||
(Stmt **)getTrailingObjects<Expr *>() + getNumExprs()); | ||
} | ||
|
||
SourceLocation getBeginLoc() const LLVM_READONLY { return BeginLoc; } | ||
SourceLocation getEndLoc() const LLVM_READONLY { return BeginLoc; } | ||
|
||
// Returns the resolved pack of a decl or nullptr | ||
static ResolvedUnexpandedPackExpr *getFromDecl(Decl *); | ||
|
||
static bool classof(const Stmt *T) { | ||
return T->getStmtClass() == ResolvedUnexpandedPackExprClass; | ||
} | ||
}; | ||
|
||
} // namespace clang | ||
|
||
#endif // LLVM_CLANG_AST_EXPRCXX_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still very much dont' want the "C" cast, but otherwise i'm ok with this.