Skip to content

Commit 2535f04

Browse files
committedAug 27, 2019
[clang] Ensure that comment classes are trivially destructible
As in D66646, these classes are also allocated with a BumpPtrAllocator, and therefore should be trivially destructible. Differential Revision: https://reviews.llvm.org/D66722 Reviewed By: Mordante, gribozavr llvm-svn: 370041
1 parent a1e5ef3 commit 2535f04

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
 

‎clang/lib/AST/Comment.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,25 @@
1313
#include "clang/AST/DeclTemplate.h"
1414
#include "clang/Basic/CharInfo.h"
1515
#include "llvm/Support/ErrorHandling.h"
16+
#include <type_traits>
1617

1718
namespace clang {
1819
namespace comments {
1920

21+
// Check that no comment class has a non-trival destructor. They are allocated
22+
// with a BumpPtrAllocator and therefore their destructor is not executed.
23+
#define ABSTRACT_COMMENT(COMMENT)
24+
#define COMMENT(CLASS, PARENT) \
25+
static_assert(std::is_trivially_destructible<CLASS>::value, \
26+
#CLASS " should be trivially destructible!");
27+
#include "clang/AST/CommentNodes.inc"
28+
#undef COMMENT
29+
#undef ABSTRACT_COMMENT
30+
31+
// DeclInfo is also allocated with a BumpPtrAllocator.
32+
static_assert(std::is_trivially_destructible<DeclInfo>::value,
33+
"DeclInfo should be trivially destructible!");
34+
2035
const char *Comment::getCommentKindName() const {
2136
switch (getCommentKind()) {
2237
case NoCommentKind: return "NoCommentKind";

0 commit comments

Comments
 (0)
Please sign in to comment.