summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2017-12-24 16:24:11 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2017-12-24 16:24:11 +0000
commit917fdbe35cac8fea618344c1639343f44fb97937 (patch)
treed5af21c1b514cd8d149b360484e95a440153a92f /clang
parentca9e57084c1e94446abc9a736131d81ff138a9af (diff)
downloadbcm5719-llvm-917fdbe35cac8fea618344c1639343f44fb97937.tar.gz
bcm5719-llvm-917fdbe35cac8fea618344c1639343f44fb97937.zip
[AST] Convert AttributedStmt to llvm::TrailingObjects.
No functionality change intended. llvm-svn: 321428
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/AST/Stmt.h11
-rw-r--r--clang/lib/AST/Stmt.cpp4
2 files changed, 8 insertions, 7 deletions
diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index 6bd07af1aff..d470392e1af 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -875,8 +875,11 @@ public:
///
/// Represents an attribute applied to a statement. For example:
/// [[omp::for(...)]] for (...) { ... }
-class AttributedStmt : public Stmt {
+class AttributedStmt final
+ : public Stmt,
+ private llvm::TrailingObjects<AttributedStmt, const Attr *> {
friend class ASTStmtReader;
+ friend TrailingObjects;
Stmt *SubStmt;
SourceLocation AttrLoc;
@@ -894,11 +897,9 @@ class AttributedStmt : public Stmt {
}
const Attr *const *getAttrArrayPtr() const {
- return reinterpret_cast<const Attr *const *>(this + 1);
- }
- const Attr **getAttrArrayPtr() {
- return reinterpret_cast<const Attr **>(this + 1);
+ return getTrailingObjects<const Attr *>();
}
+ const Attr **getAttrArrayPtr() { return getTrailingObjects<const Attr *>(); }
public:
static AttributedStmt *Create(const ASTContext &C, SourceLocation Loc,
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp
index 8d240c1336a..773b4da940b 100644
--- a/clang/lib/AST/Stmt.cpp
+++ b/clang/lib/AST/Stmt.cpp
@@ -334,7 +334,7 @@ AttributedStmt *AttributedStmt::Create(const ASTContext &C, SourceLocation Loc,
ArrayRef<const Attr*> Attrs,
Stmt *SubStmt) {
assert(!Attrs.empty() && "Attrs should not be empty");
- void *Mem = C.Allocate(sizeof(AttributedStmt) + sizeof(Attr *) * Attrs.size(),
+ void *Mem = C.Allocate(totalSizeToAlloc<const Attr *>(Attrs.size()),
alignof(AttributedStmt));
return new (Mem) AttributedStmt(Loc, Attrs, SubStmt);
}
@@ -342,7 +342,7 @@ AttributedStmt *AttributedStmt::Create(const ASTContext &C, SourceLocation Loc,
AttributedStmt *AttributedStmt::CreateEmpty(const ASTContext &C,
unsigned NumAttrs) {
assert(NumAttrs > 0 && "NumAttrs should be greater than zero");
- void *Mem = C.Allocate(sizeof(AttributedStmt) + sizeof(Attr *) * NumAttrs,
+ void *Mem = C.Allocate(totalSizeToAlloc<const Attr *>(NumAttrs),
alignof(AttributedStmt));
return new (Mem) AttributedStmt(EmptyShell(), NumAttrs);
}
OpenPOWER on IntegriCloud