|
@@ -4844,31 +4844,46 @@ public:
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
-class ParenListExpr : public Expr {
|
|
|
|
- Stmt **Exprs;
|
|
|
|
- unsigned NumExprs;
|
|
|
|
|
|
+class ParenListExpr final
|
|
|
|
+ : public Expr,
|
|
|
|
+ private llvm::TrailingObjects<ParenListExpr, Stmt *> {
|
|
|
|
+ friend class ASTStmtReader;
|
|
|
|
+ friend TrailingObjects;
|
|
|
|
+
|
|
|
|
+ /// The location of the left and right parentheses.
|
|
SourceLocation LParenLoc, RParenLoc;
|
|
SourceLocation LParenLoc, RParenLoc;
|
|
|
|
|
|
-public:
|
|
|
|
- ParenListExpr(const ASTContext& C, SourceLocation lparenloc,
|
|
|
|
- ArrayRef<Expr*> exprs, SourceLocation rparenloc);
|
|
|
|
|
|
+ /// Build a paren list.
|
|
|
|
+ ParenListExpr(SourceLocation LParenLoc, ArrayRef<Expr *> Exprs,
|
|
|
|
+ SourceLocation RParenLoc);
|
|
|
|
|
|
/// Build an empty paren list.
|
|
/// Build an empty paren list.
|
|
- explicit ParenListExpr(EmptyShell Empty) : Expr(ParenListExprClass, Empty) { }
|
|
|
|
|
|
+ ParenListExpr(EmptyShell Empty, unsigned NumExprs);
|
|
|
|
+
|
|
|
|
+public:
|
|
|
|
+ /// Create a paren list.
|
|
|
|
+ static ParenListExpr *Create(const ASTContext &Ctx, SourceLocation LParenLoc,
|
|
|
|
+ ArrayRef<Expr *> Exprs,
|
|
|
|
+ SourceLocation RParenLoc);
|
|
|
|
+
|
|
|
|
+ /// Create an empty paren list.
|
|
|
|
+ static ParenListExpr *CreateEmpty(const ASTContext &Ctx, unsigned NumExprs);
|
|
|
|
|
|
- unsigned getNumExprs() const { return NumExprs; }
|
|
|
|
|
|
+ /// Return the number of expressions in this paren list.
|
|
|
|
+ unsigned getNumExprs() const { return ParenListExprBits.NumExprs; }
|
|
|
|
|
|
- const Expr* getExpr(unsigned Init) const {
|
|
|
|
|
|
+ Expr *getExpr(unsigned Init) {
|
|
assert(Init < getNumExprs() && "Initializer access out of range!");
|
|
assert(Init < getNumExprs() && "Initializer access out of range!");
|
|
- return cast_or_null<Expr>(Exprs[Init]);
|
|
|
|
|
|
+ return getExprs()[Init];
|
|
}
|
|
}
|
|
|
|
|
|
- Expr* getExpr(unsigned Init) {
|
|
|
|
- assert(Init < getNumExprs() && "Initializer access out of range!");
|
|
|
|
- return cast_or_null<Expr>(Exprs[Init]);
|
|
|
|
|
|
+ const Expr *getExpr(unsigned Init) const {
|
|
|
|
+ return const_cast<ParenListExpr *>(this)->getExpr(Init);
|
|
}
|
|
}
|
|
|
|
|
|
- Expr **getExprs() { return reinterpret_cast<Expr **>(Exprs); }
|
|
|
|
|
|
+ Expr **getExprs() {
|
|
|
|
+ return reinterpret_cast<Expr **>(getTrailingObjects<Stmt *>());
|
|
|
|
+ }
|
|
|
|
|
|
ArrayRef<Expr *> exprs() {
|
|
ArrayRef<Expr *> exprs() {
|
|
return llvm::makeArrayRef(getExprs(), getNumExprs());
|
|
return llvm::makeArrayRef(getExprs(), getNumExprs());
|
|
@@ -4876,9 +4891,8 @@ public:
|
|
|
|
|
|
SourceLocation getLParenLoc() const { return LParenLoc; }
|
|
SourceLocation getLParenLoc() const { return LParenLoc; }
|
|
SourceLocation getRParenLoc() const { return RParenLoc; }
|
|
SourceLocation getRParenLoc() const { return RParenLoc; }
|
|
-
|
|
|
|
- SourceLocation getBeginLoc() const LLVM_READONLY { return LParenLoc; }
|
|
|
|
- SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
|
|
|
|
|
|
+ SourceLocation getBeginLoc() const { return getLParenLoc(); }
|
|
|
|
+ SourceLocation getEndLoc() const { return getRParenLoc(); }
|
|
|
|
|
|
static bool classof(const Stmt *T) {
|
|
static bool classof(const Stmt *T) {
|
|
return T->getStmtClass() == ParenListExprClass;
|
|
return T->getStmtClass() == ParenListExprClass;
|
|
@@ -4886,14 +4900,13 @@ public:
|
|
|
|
|
|
// Iterators
|
|
// Iterators
|
|
child_range children() {
|
|
child_range children() {
|
|
- return child_range(&Exprs[0], &Exprs[0]+NumExprs);
|
|
|
|
|
|
+ return child_range(getTrailingObjects<Stmt *>(),
|
|
|
|
+ getTrailingObjects<Stmt *>() + getNumExprs());
|
|
}
|
|
}
|
|
const_child_range children() const {
|
|
const_child_range children() const {
|
|
- return const_child_range(&Exprs[0], &Exprs[0] + NumExprs);
|
|
|
|
|
|
+ return const_child_range(getTrailingObjects<Stmt *>(),
|
|
|
|
+ getTrailingObjects<Stmt *>() + getNumExprs());
|
|
}
|
|
}
|
|
-
|
|
|
|
- friend class ASTStmtReader;
|
|
|
|
- friend class ASTStmtWriter;
|
|
|
|
};
|
|
};
|
|
|
|
|
|
/// Represents a C11 generic selection.
|
|
/// Represents a C11 generic selection.
|