r370041 - [clang] Ensure that comment classes are trivially destructible
Bruno Ricci via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 27 04:21:00 PDT 2019
Author: brunoricci
Date: Tue Aug 27 04:21:00 2019
New Revision: 370041
URL: http://llvm.org/viewvc/llvm-project?rev=370041&view=rev
Log:
[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
Modified:
cfe/trunk/lib/AST/Comment.cpp
Modified: cfe/trunk/lib/AST/Comment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Comment.cpp?rev=370041&r1=370040&r2=370041&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Comment.cpp (original)
+++ cfe/trunk/lib/AST/Comment.cpp Tue Aug 27 04:21:00 2019
@@ -13,10 +13,25 @@
#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
+
+// DeclInfo is also allocated with a BumpPtrAllocator.
+static_assert(std::is_trivially_destructible<DeclInfo>::value,
+ "DeclInfo should be trivially destructible!");
+
const char *Comment::getCommentKindName() const {
switch (getCommentKind()) {
case NoCommentKind: return "NoCommentKind";
More information about the cfe-commits
mailing list