Index: clang/lib/AST/Stmt.cpp =================================================================== --- clang/lib/AST/Stmt.cpp +++ clang/lib/AST/Stmt.cpp @@ -83,6 +83,16 @@ #CLASS " should not be polymorphic!"); #include "clang/AST/StmtNodes.inc" +// Check that no statement / expression class has a non-trival destructor. +// Statements and expressions are allocated with the BumpPtrAllocator from +// ASTContext and therefore their destructor is not executed. +#define STMT(CLASS, PARENT) \ + static_assert(std::is_trivially_destructible::value, \ + #CLASS " should be trivially destructible!"); +// FIXME: InitListExpr is not trivially destructible due to its ASTVector. +#define INITLISTEXPR(CLASS, PARENT) +#include "clang/AST/StmtNodes.inc" + void Stmt::PrintStats() { // Ensure the table is primed. getStmtInfoTableEntry(Stmt::NullStmtClass); Index: clang/lib/AST/Type.cpp =================================================================== --- clang/lib/AST/Type.cpp +++ clang/lib/AST/Type.cpp @@ -299,6 +299,18 @@ #CLASS "Type should not be polymorphic!"); #include "clang/AST/TypeNodes.def" +// Check that no type class has a non-trival destructor. Types are +// allocated with the BumpPtrAllocator from ASTContext and therefore +// their destructor is not executed. +// +// FIXME: ConstantArrayType is not trivially destructible because of its +// APInt member. It should be replaced in favor of ASTContext allocation. +#define TYPE(CLASS, BASE) \ + static_assert(std::is_trivially_destructible::value || \ + std::is_same::value, \ + #CLASS "Type should be trivially destructible!"); +#include "clang/AST/TypeNodes.def" + QualType Type::getLocallyUnqualifiedSingleStepDesugaredType() const { switch (getTypeClass()) { #define ABSTRACT_TYPE(Class, Parent)