diff options
Diffstat (limited to 'include/clang/AST/DeclFriend.h')
| -rw-r--r-- | include/clang/AST/DeclFriend.h | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/include/clang/AST/DeclFriend.h b/include/clang/AST/DeclFriend.h index 12b93b408a70..27b0388007a1 100644 --- a/include/clang/AST/DeclFriend.h +++ b/include/clang/AST/DeclFriend.h @@ -37,7 +37,9 @@ namespace clang { /// @endcode /// /// The semantic context of a friend decl is its declaring class. -class FriendDecl : public Decl { +class FriendDecl final + : public Decl, + private llvm::TrailingObjects<FriendDecl, TemplateParameterList *> { virtual void anchor(); public: typedef llvm::PointerUnion<NamedDecl*,TypeSourceInfo*> FriendUnion; @@ -62,14 +64,6 @@ private: // template <class T> friend class A<T>::B; unsigned NumTPLists : 31; - // The tail-allocated friend type template parameter lists (if any). - TemplateParameterList* const *getTPLists() const { - return reinterpret_cast<TemplateParameterList* const *>(this + 1); - } - TemplateParameterList **getTPLists() { - return reinterpret_cast<TemplateParameterList**>(this + 1); - } - friend class CXXRecordDecl::friend_iterator; friend class CXXRecordDecl; @@ -83,7 +77,7 @@ private: UnsupportedFriend(false), NumTPLists(FriendTypeTPLists.size()) { for (unsigned i = 0; i < NumTPLists; ++i) - getTPLists()[i] = FriendTypeTPLists[i]; + getTrailingObjects<TemplateParameterList *>()[i] = FriendTypeTPLists[i]; } FriendDecl(EmptyShell Empty, unsigned NumFriendTypeTPLists) @@ -118,7 +112,7 @@ public: } TemplateParameterList *getFriendTypeTemplateParameterList(unsigned N) const { assert(N < NumTPLists); - return getTPLists()[N]; + return getTrailingObjects<TemplateParameterList *>()[N]; } /// If this friend declaration doesn't name a type, return the inner @@ -148,9 +142,10 @@ public: return SourceRange(getFriendLoc(), ND->getLocEnd()); } else if (TypeSourceInfo *TInfo = getFriendType()) { - SourceLocation StartL = (NumTPLists == 0) - ? getFriendLoc() - : getTPLists()[0]->getTemplateLoc(); + SourceLocation StartL = + (NumTPLists == 0) ? getFriendLoc() + : getTrailingObjects<TemplateParameterList *>()[0] + ->getTemplateLoc(); return SourceRange(StartL, TInfo->getTypeLoc().getEndLoc()); } else @@ -171,6 +166,7 @@ public: friend class ASTDeclReader; friend class ASTDeclWriter; + friend TrailingObjects; }; /// An iterator over the friend declarations of a class. |
