Author: brunoricci Date: Tue Dec 4 08:04:19 2018 New Revision: 348278 URL: http://llvm.org/viewvc/llvm-project?rev=348278&view=rev Log: [AST] Assert that no statement/expression class is polymorphic
Add a static_assert checking that no statement/expression class is polymorphic. People should use LLVM style RTTI instead. Differential Revision: https://reviews.llvm.org/D55222 Reviewed By: aaron.ballman Modified: cfe/trunk/lib/AST/Stmt.cpp Modified: cfe/trunk/lib/AST/Stmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=348278&r1=348277&r2=348278&view=diff ============================================================================== --- cfe/trunk/lib/AST/Stmt.cpp (original) +++ cfe/trunk/lib/AST/Stmt.cpp Tue Dec 4 08:04:19 2018 @@ -76,6 +76,14 @@ const char *Stmt::getStmtClassName() con return getStmtInfoTableEntry((StmtClass) StmtBits.sClass).Name; } +// Check that no statement / expression class is polymorphic. LLVM style RTTI +// should be used instead. If absolutely needed an exception can still be added +// here by defining the appropriate macro (but please don't do this). +#define STMT(CLASS, PARENT) \ + static_assert(!std::is_polymorphic<CLASS>::value, \ + #CLASS " should not be polymorphic!"); +#include "clang/AST/StmtNodes.inc" + void Stmt::PrintStats() { // Ensure the table is primed. getStmtInfoTableEntry(Stmt::NullStmtClass); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits