summaryrefslogtreecommitdiffstats
path: root/include/clang/AST/Expr.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/AST/Expr.h')
-rw-r--r--include/clang/AST/Expr.h28
1 files changed, 18 insertions, 10 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index f9f1995..095dd6a 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -2190,7 +2190,8 @@ public:
return reinterpret_cast<Expr **>(SubExprs+getNumPreArgs()+PREARGS_START);
}
const Expr *const *getArgs() const {
- return const_cast<CallExpr*>(this)->getArgs();
+ return reinterpret_cast<Expr **>(SubExprs + getNumPreArgs() +
+ PREARGS_START);
}
/// getArg - Return the specified argument.
@@ -3926,7 +3927,9 @@ public:
/// which covers @c [2].y=1.0. This DesignatedInitExpr will have two
/// designators, one array designator for @c [2] followed by one field
/// designator for @c .y. The initialization expression will be 1.0.
-class DesignatedInitExpr : public Expr {
+class DesignatedInitExpr final
+ : public Expr,
+ private llvm::TrailingObjects<DesignatedInitExpr, Stmt *> {
public:
/// \brief Forward declaration of the Designator class.
class Designator;
@@ -4206,12 +4209,12 @@ public:
Expr *getSubExpr(unsigned Idx) const {
assert(Idx < NumSubExprs && "Subscript out of range");
- return cast<Expr>(reinterpret_cast<Stmt *const *>(this + 1)[Idx]);
+ return cast<Expr>(getTrailingObjects<Stmt *>()[Idx]);
}
void setSubExpr(unsigned Idx, Expr *E) {
assert(Idx < NumSubExprs && "Subscript out of range");
- reinterpret_cast<Stmt **>(this + 1)[Idx] = E;
+ getTrailingObjects<Stmt *>()[Idx] = E;
}
/// \brief Replaces the designator at index @p Idx with the series
@@ -4230,9 +4233,11 @@ public:
// Iterators
child_range children() {
- Stmt **begin = reinterpret_cast<Stmt**>(this + 1);
+ Stmt **begin = getTrailingObjects<Stmt *>();
return child_range(begin, begin + NumSubExprs);
}
+
+ friend TrailingObjects;
};
/// \brief Represents a place-holder for an object not to be initialized by
@@ -4683,7 +4688,9 @@ public:
/// equivalent to a particular message send, and this is very much
/// part of the user model. The name of this class encourages this
/// modelling design.
-class PseudoObjectExpr : public Expr {
+class PseudoObjectExpr final
+ : public Expr,
+ private llvm::TrailingObjects<PseudoObjectExpr, Expr *> {
// PseudoObjectExprBits.NumSubExprs - The number of sub-expressions.
// Always at least two, because the first sub-expression is the
// syntactic form.
@@ -4695,13 +4702,11 @@ class PseudoObjectExpr : public Expr {
// in to Create, which is an index within the semantic forms.
// Note also that ASTStmtWriter assumes this encoding.
- Expr **getSubExprsBuffer() { return reinterpret_cast<Expr**>(this + 1); }
+ Expr **getSubExprsBuffer() { return getTrailingObjects<Expr *>(); }
const Expr * const *getSubExprsBuffer() const {
- return reinterpret_cast<const Expr * const *>(this + 1);
+ return getTrailingObjects<Expr *>();
}
- friend class ASTStmtReader;
-
PseudoObjectExpr(QualType type, ExprValueKind VK,
Expr *syntactic, ArrayRef<Expr*> semantic,
unsigned resultIndex);
@@ -4798,6 +4803,9 @@ public:
static bool classof(const Stmt *T) {
return T->getStmtClass() == PseudoObjectExprClass;
}
+
+ friend TrailingObjects;
+ friend class ASTStmtReader;
};
/// AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*,
OpenPOWER on IntegriCloud