[PATCH] D66722: [clang] Ensure that comment classes are trivially destructible
Bruno Ricci via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 25 12:00:33 PDT 2019
riccibruno created this revision.
riccibruno added reviewers: aaron.ballman, Mordante.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.
As in D66646 <https://reviews.llvm.org/D66646>, these classes are also allocated with a `BumpPtrAllocator`, and therefore should be trivially destructible.
Repository:
rC Clang
https://reviews.llvm.org/D66722
Files:
clang/lib/AST/Comment.cpp
Index: clang/lib/AST/Comment.cpp
===================================================================
--- clang/lib/AST/Comment.cpp
+++ clang/lib/AST/Comment.cpp
@@ -13,10 +13,21 @@
#include "clang/AST/DeclTemplate.h"
#include "clang/Basic/CharInfo.h"
#include "llvm/Support/ErrorHandling.h"
+#include <type_traits>
namespace clang {
namespace comments {
+// Check that no comment class has a non-trival destructor. They are allocated
+// with a BumpPtrAllocator and therefore their destructor is not executed.
+#define ABSTRACT_COMMENT(COMMENT)
+#define COMMENT(CLASS, PARENT) \
+ static_assert(std::is_trivially_destructible<CLASS>::value, \
+ #CLASS " should be trivially destructible!");
+#include "clang/AST/CommentNodes.inc"
+#undef COMMENT
+#undef ABSTRACT_COMMENT
+
const char *Comment::getCommentKindName() const {
switch (getCommentKind()) {
case NoCommentKind: return "NoCommentKind";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66722.217060.patch
Type: text/x-patch
Size: 992 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190825/1e64e292/attachment.bin>
More information about the cfe-commits
mailing list